Файловый менеджер - Редактировать - /www/wwwroot/gamenworld.store/themes/tooltemptwo/js/antd.js
�азад
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react")); else if(typeof define === 'function' && define.amd) define(["react"], factory); else if(typeof exports === 'object') exports["antd"] = factory(require("react")); else root["antd"] = factory(root["React"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_76__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; __webpack_require__(73); // matchMedia polyfill for // https://github.com/WickyNilliams/enquire.js/issues/82 window.matchMedia = window.matchMedia || function () { return { matches: false, addListener: function addListener() {}, removeListener: function removeListener() {} }; }; var antd = { Affix: __webpack_require__(75), Datepicker: __webpack_require__(89), Tooltip: __webpack_require__(136), Carousel: __webpack_require__(151), Tabs: __webpack_require__(185), Modal: __webpack_require__(193), Dropdown: __webpack_require__(209), Progress: __webpack_require__(212), Popover: __webpack_require__(216), Select: __webpack_require__(217), Breadcrumb: __webpack_require__(249), Popconfirm: __webpack_require__(250), Pagination: __webpack_require__(251), confirm: __webpack_require__(208), Steps: __webpack_require__(257), InputNumber: __webpack_require__(261), Switch: __webpack_require__(264), Checkbox: __webpack_require__(267), Table: __webpack_require__(271), Tag: __webpack_require__(277), Collapse: __webpack_require__(278), message: __webpack_require__(285), Slider: __webpack_require__(288), EnterAnimation: __webpack_require__(291), Radio: __webpack_require__(299), Notification: __webpack_require__(304), Alert: __webpack_require__(305), Validation: __webpack_require__(306), Tree: __webpack_require__(335), Upload: __webpack_require__(341), Badge: __webpack_require__(353), Menu: __webpack_require__(354), Timeline: __webpack_require__(355) }; // deprecate antd.confirm antd.confirm = __webpack_require__(356)(antd.confirm, 'antd.confirm() is deprecated, use antd.Modal.confirm() instead'); module.exports = antd; antd.version = __webpack_require__(357).version; /***/ }, /* 1 */, /* 2 */, /* 3 */, /* 4 */, /* 5 */, /* 6 */, /* 7 */, /* 8 */, /* 9 */, /* 10 */, /* 11 */, /* 12 */, /* 13 */, /* 14 */, /* 15 */, /* 16 */, /* 17 */, /* 18 */, /* 19 */, /* 20 */, /* 21 */, /* 22 */, /* 23 */, /* 24 */, /* 25 */, /* 26 */, /* 27 */, /* 28 */, /* 29 */, /* 30 */, /* 31 */, /* 32 */, /* 33 */, /* 34 */, /* 35 */, /* 36 */, /* 37 */, /* 38 */, /* 39 */, /* 40 */, /* 41 */, /* 42 */, /* 43 */, /* 44 */, /* 45 */, /* 46 */, /* 47 */, /* 48 */, /* 49 */, /* 50 */, /* 51 */, /* 52 */, /* 53 */, /* 54 */, /* 55 */, /* 56 */, /* 57 */, /* 58 */, /* 59 */, /* 60 */, /* 61 */, /* 62 */, /* 63 */, /* 64 */, /* 65 */, /* 66 */, /* 67 */, /* 68 */, /* 69 */, /* 70 */, /* 71 */, /* 72 */, /* 73 */ /***/ function(module, exports) { // removed by extract-text-webpack-plugin /***/ }, /* 74 */, /* 75 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; //ie6,7,8 standard mode ret = d.documentElement[method]; if (typeof ret !== 'number') { //quirks mode ret = d.body[method]; } } return ret; } function getOffset(element) { var rect = element.getBoundingClientRect(); var body = document.body; var clientTop = element.clientTop || body.clientTop || 0; var clientLeft = element.clientLeft || body.clientLeft || 0; var scrollTop = getScroll(window, true); var scrollLeft = getScroll(window); return { top: rect.top + scrollTop - clientTop, left: rect.left + scrollLeft - clientLeft }; } var Affix = _react2['default'].createClass({ displayName: 'Affix', getDefaultProps: function getDefaultProps() { return { offset: 0 }; }, propTypes: { offset: _react2['default'].PropTypes.number }, getInitialState: function getInitialState() { return { affix: false, affixStyle: null }; }, handleScroll: function handleScroll() { var affix = this.state.affix; var scrollTop = getScroll(window, true); var elemOffset = getOffset(this.getDOMNode()); if (!affix && elemOffset.top - this.props.offset < scrollTop) { this.setState({ affix: true, affixStyle: { top: this.props.offset, left: elemOffset.left, width: this.getDOMNode().offsetWidth } }); } if (affix && elemOffset.top - this.props.offset > scrollTop) { this.setState({ affix: false, affixStyle: null }); } }, componentDidMount: function componentDidMount() { this.scrollEvent = _rcUtil2['default'].Dom.addEventListener(window, 'scroll', this.handleScroll); this.resizeEvent = _rcUtil2['default'].Dom.addEventListener(window, 'resize', this.handleScroll); }, componentWillUnmount: function componentWillUnmount() { if (this.scrollEvent) { this.scrollEvent.remove(); } if (this.resizeEvent) { this.resizeEvent.remove(); } }, render: function render() { var _rcUtil$classSet; var className = _rcUtil2['default'].classSet((_rcUtil$classSet = {}, _defineProperty(_rcUtil$classSet, this.props.className, this.props.className), _defineProperty(_rcUtil$classSet, 'ant-affix', this.state.affix), _rcUtil$classSet)); return _react2['default'].createElement( 'div', this.props, _react2['default'].createElement( 'div', { className: className, style: this.state.affixStyle }, this.props.children ) ); } }); module.exports = Affix; /***/ }, /* 76 */ /***/ function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_76__; /***/ }, /* 77 */ /***/ function(module, exports, __webpack_require__) { module.exports = { guid: __webpack_require__(78), classSet: __webpack_require__(79), joinClasses: __webpack_require__(80), KeyCode: __webpack_require__(81), PureRenderMixin: __webpack_require__(82), shallowEqual: __webpack_require__(83), createChainedFunction: __webpack_require__(84), Dom: { addEventListener: __webpack_require__(85), contains: __webpack_require__(86) }, Children: { toArray: __webpack_require__(87), mapSelf: __webpack_require__(88) } }; /***/ }, /* 78 */ /***/ function(module, exports) { var seed = 0; module.exports = function () { return Date.now() + '_' + (seed++); }; /***/ }, /* 79 */ /***/ function(module, exports) { /** * Copyright 2013-2014, Facebook, Inc. * All rights reserved. * * This file contains an unmodified version of: * https://github.com/facebook/react/blob/v0.12.0/src/vendor/stubs/cx.js * * This source code is licensed under the BSD-style license found here: * https://github.com/facebook/react/blob/v0.12.0/LICENSE * An additional grant of patent rights can be found here: * https://github.com/facebook/react/blob/v0.12.0/PATENTS */ /** * This function is used to mark string literals representing CSS class names * so that they can be transformed statically. This allows for modularization * and minification of CSS class names. * * In static_upstream, this function is actually implemented, but it should * eventually be replaced with something more descriptive, and the transform * that is used in the main stack should be ported for use elsewhere. * * @param string|object className to modularize, or an object of key/values. * In the object case, the values are conditions that * determine if the className keys should be included. * @param [string ...] Variable list of classNames in the string case. * @return string Renderable space-separated CSS className. */ function cx(classNames) { if (typeof classNames === 'object') { return Object.keys(classNames).filter(function(className) { return classNames[className]; }).join(' '); } else { return Array.prototype.join.call(arguments, ' '); } } module.exports = cx; /***/ }, /* 80 */ /***/ function(module, exports) { /** * Copyright 2013-2014, Facebook, Inc. * All rights reserved. * * This file contains an unmodified version of: * https://github.com/facebook/react/blob/v0.12.0/src/utils/joinClasses.js * * This source code is licensed under the BSD-style license found here: * https://github.com/facebook/react/blob/v0.12.0/LICENSE * An additional grant of patent rights can be found here: * https://github.com/facebook/react/blob/v0.12.0/PATENTS */ "use strict"; /** * Combines multiple className strings into one. * http://jsperf.com/joinclasses-args-vs-array * * @param {...?string} classes * @return {string} */ function joinClasses(className /*, ... */ ) { if (!className) { className = ''; } var nextClass; var argLength = arguments.length; if (argLength > 1) { for (var ii = 1; ii < argLength; ii++) { nextClass = arguments[ii]; if (nextClass) { className = (className ? className + ' ' : '') + nextClass; } } } return className; } module.exports = joinClasses; /***/ }, /* 81 */ /***/ function(module, exports) { /** * @ignore * some key-codes definition and utils from closure-library * @author yiminghe@gmail.com */ var KeyCode = { /** * MAC_ENTER */ MAC_ENTER: 3, /** * BACKSPACE */ BACKSPACE: 8, /** * TAB */ TAB: 9, /** * NUMLOCK on FF/Safari Mac */ NUM_CENTER: 12, // NUMLOCK on FF/Safari Mac /** * ENTER */ ENTER: 13, /** * SHIFT */ SHIFT: 16, /** * CTRL */ CTRL: 17, /** * ALT */ ALT: 18, /** * PAUSE */ PAUSE: 19, /** * CAPS_LOCK */ CAPS_LOCK: 20, /** * ESC */ ESC: 27, /** * SPACE */ SPACE: 32, /** * PAGE_UP */ PAGE_UP: 33, // also NUM_NORTH_EAST /** * PAGE_DOWN */ PAGE_DOWN: 34, // also NUM_SOUTH_EAST /** * END */ END: 35, // also NUM_SOUTH_WEST /** * HOME */ HOME: 36, // also NUM_NORTH_WEST /** * LEFT */ LEFT: 37, // also NUM_WEST /** * UP */ UP: 38, // also NUM_NORTH /** * RIGHT */ RIGHT: 39, // also NUM_EAST /** * DOWN */ DOWN: 40, // also NUM_SOUTH /** * PRINT_SCREEN */ PRINT_SCREEN: 44, /** * INSERT */ INSERT: 45, // also NUM_INSERT /** * DELETE */ DELETE: 46, // also NUM_DELETE /** * ZERO */ ZERO: 48, /** * ONE */ ONE: 49, /** * TWO */ TWO: 50, /** * THREE */ THREE: 51, /** * FOUR */ FOUR: 52, /** * FIVE */ FIVE: 53, /** * SIX */ SIX: 54, /** * SEVEN */ SEVEN: 55, /** * EIGHT */ EIGHT: 56, /** * NINE */ NINE: 57, /** * QUESTION_MARK */ QUESTION_MARK: 63, // needs localization /** * A */ A: 65, /** * B */ B: 66, /** * C */ C: 67, /** * D */ D: 68, /** * E */ E: 69, /** * F */ F: 70, /** * G */ G: 71, /** * H */ H: 72, /** * I */ I: 73, /** * J */ J: 74, /** * K */ K: 75, /** * L */ L: 76, /** * M */ M: 77, /** * N */ N: 78, /** * O */ O: 79, /** * P */ P: 80, /** * Q */ Q: 81, /** * R */ R: 82, /** * S */ S: 83, /** * T */ T: 84, /** * U */ U: 85, /** * V */ V: 86, /** * W */ W: 87, /** * X */ X: 88, /** * Y */ Y: 89, /** * Z */ Z: 90, /** * META */ META: 91, // WIN_KEY_LEFT /** * WIN_KEY_RIGHT */ WIN_KEY_RIGHT: 92, /** * CONTEXT_MENU */ CONTEXT_MENU: 93, /** * NUM_ZERO */ NUM_ZERO: 96, /** * NUM_ONE */ NUM_ONE: 97, /** * NUM_TWO */ NUM_TWO: 98, /** * NUM_THREE */ NUM_THREE: 99, /** * NUM_FOUR */ NUM_FOUR: 100, /** * NUM_FIVE */ NUM_FIVE: 101, /** * NUM_SIX */ NUM_SIX: 102, /** * NUM_SEVEN */ NUM_SEVEN: 103, /** * NUM_EIGHT */ NUM_EIGHT: 104, /** * NUM_NINE */ NUM_NINE: 105, /** * NUM_MULTIPLY */ NUM_MULTIPLY: 106, /** * NUM_PLUS */ NUM_PLUS: 107, /** * NUM_MINUS */ NUM_MINUS: 109, /** * NUM_PERIOD */ NUM_PERIOD: 110, /** * NUM_DIVISION */ NUM_DIVISION: 111, /** * F1 */ F1: 112, /** * F2 */ F2: 113, /** * F3 */ F3: 114, /** * F4 */ F4: 115, /** * F5 */ F5: 116, /** * F6 */ F6: 117, /** * F7 */ F7: 118, /** * F8 */ F8: 119, /** * F9 */ F9: 120, /** * F10 */ F10: 121, /** * F11 */ F11: 122, /** * F12 */ F12: 123, /** * NUMLOCK */ NUMLOCK: 144, /** * SEMICOLON */ SEMICOLON: 186, // needs localization /** * DASH */ DASH: 189, // needs localization /** * EQUALS */ EQUALS: 187, // needs localization /** * COMMA */ COMMA: 188, // needs localization /** * PERIOD */ PERIOD: 190, // needs localization /** * SLASH */ SLASH: 191, // needs localization /** * APOSTROPHE */ APOSTROPHE: 192, // needs localization /** * SINGLE_QUOTE */ SINGLE_QUOTE: 222, // needs localization /** * OPEN_SQUARE_BRACKET */ OPEN_SQUARE_BRACKET: 219, // needs localization /** * BACKSLASH */ BACKSLASH: 220, // needs localization /** * CLOSE_SQUARE_BRACKET */ CLOSE_SQUARE_BRACKET: 221, // needs localization /** * WIN_KEY */ WIN_KEY: 224, /** * MAC_FF_META */ MAC_FF_META: 224, // Firefox (Gecko) fires this for the meta key instead of 91 /** * WIN_IME */ WIN_IME: 229 }; /* whether text and modified key is entered at the same time. */ KeyCode.isTextModifyingKeyEvent = function (e) { var keyCode = e.keyCode; if (e.altKey && !e.ctrlKey || e.metaKey || // Function keys don't generate text keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) { return false; } // The following keys are quite harmless, even in combination with // CTRL, ALT or SHIFT. switch (keyCode) { case KeyCode.ALT: case KeyCode.CAPS_LOCK: case KeyCode.CONTEXT_MENU: case KeyCode.CTRL: case KeyCode.DOWN: case KeyCode.END: case KeyCode.ESC: case KeyCode.HOME: case KeyCode.INSERT: case KeyCode.LEFT: case KeyCode.MAC_FF_META: case KeyCode.META: case KeyCode.NUMLOCK: case KeyCode.NUM_CENTER: case KeyCode.PAGE_DOWN: case KeyCode.PAGE_UP: case KeyCode.PAUSE: case KeyCode.PRINT_SCREEN: case KeyCode.RIGHT: case KeyCode.SHIFT: case KeyCode.UP: case KeyCode.WIN_KEY: case KeyCode.WIN_KEY_RIGHT: return false; default: return true; } }; /* whether character is entered. */ KeyCode.isCharacterKey = function (keyCode) { if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) { return true; } if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) { return true; } if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) { return true; } // Safari sends zero key code for non-latin characters. if (window.navigation.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) { return true; } switch (keyCode) { case KeyCode.SPACE: case KeyCode.QUESTION_MARK: case KeyCode.NUM_PLUS: case KeyCode.NUM_MINUS: case KeyCode.NUM_PERIOD: case KeyCode.NUM_DIVISION: case KeyCode.SEMICOLON: case KeyCode.DASH: case KeyCode.EQUALS: case KeyCode.COMMA: case KeyCode.PERIOD: case KeyCode.SLASH: case KeyCode.APOSTROPHE: case KeyCode.SINGLE_QUOTE: case KeyCode.OPEN_SQUARE_BRACKET: case KeyCode.BACKSLASH: case KeyCode.CLOSE_SQUARE_BRACKET: return true; default: return false; } }; module.exports = KeyCode; /***/ }, /* 82 */ /***/ function(module, exports, __webpack_require__) { /** * Copyright 2013-2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ReactComponentWithPureRenderMixin */ "use strict"; var shallowEqual = __webpack_require__(83); /** * If your React component's render function is "pure", e.g. it will render the * same result given the same props and state, provide this Mixin for a * considerable performance boost. * * Most React components have pure render functions. * * Example: * * var ReactComponentWithPureRenderMixin = * require('ReactComponentWithPureRenderMixin'); * React.createClass({ * mixins: [ReactComponentWithPureRenderMixin], * * render: function() { * return <div className={this.props.className}>foo</div>; * } * }); * * Note: This only checks shallow equality for props and state. If these contain * complex data structures this mixin may have false-negatives for deeper * differences. Only mixin to components which have simple props and state, or * use `forceUpdate()` when you know deep data structures have changed. */ var ReactComponentWithPureRenderMixin = { shouldComponentUpdate: function(nextProps, nextState) { return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState); } }; module.exports = ReactComponentWithPureRenderMixin; /***/ }, /* 83 */ /***/ function(module, exports) { /** * Copyright 2013-2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule shallowEqual */ "use strict"; /** * Performs equality by iterating through keys on an object and returning * false when any key has values which are not strictly equal between * objA and objB. Returns true when the values of all keys are strictly equal. * * @return {boolean} */ function shallowEqual(objA, objB) { if (objA === objB) { return true; } var key; // Test for A's keys different from B. for (key in objA) { if (objA.hasOwnProperty(key) && (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) { return false; } } // Test for B's keys missing from A. for (key in objB) { if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) { return false; } } return true; } module.exports = shallowEqual; /***/ }, /* 84 */ /***/ function(module, exports) { /** * Safe chained function * * Will only create a new function if needed, * otherwise will pass back existing functions or null. * * @returns {function|null} */ function createChainedFunction() { var args = arguments; return function chainedFunction() { for (var i = 0; i < args.length; i++) { if (args[i] && args[i].apply) { args[i].apply(this, arguments); } } }; } module.exports = createChainedFunction; /***/ }, /* 85 */ /***/ function(module, exports) { module.exports = function (target, eventType, callback) { if (target.addEventListener) { target.addEventListener(eventType, callback, false); return { remove: function () { target.removeEventListener(eventType, callback, false); } }; } else if (target.attachEvent) { target.attachEvent('on' + eventType, callback); return { remove: function () { target.detachEvent('on' + eventType, callback); } }; } }; /***/ }, /* 86 */ /***/ function(module, exports) { module.exports = function (root, node) { while (node) { if (node === root) { return true; } node = node.parentNode; } return false; }; /***/ }, /* 87 */ /***/ function(module, exports, __webpack_require__) { var React = __webpack_require__(76); module.exports = function (children) { var ret = []; React.Children.forEach(children, function (c) { ret.push(c); }); return ret; }; /***/ }, /* 88 */ /***/ function(module, exports, __webpack_require__) { var React = __webpack_require__(76); function mirror(o) { return o; } module.exports = function (children) { // return ReactFragment return React.Children.map(children, mirror); }; /***/ }, /* 89 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcCalendar = __webpack_require__(90); var _rcCalendar2 = _interopRequireDefault(_rcCalendar); var _gregorianCalendar = __webpack_require__(94); var _gregorianCalendar2 = _interopRequireDefault(_gregorianCalendar); var _gregorianCalendarLibLocaleZhCn = __webpack_require__(133); var _gregorianCalendarLibLocaleZhCn2 = _interopRequireDefault(_gregorianCalendarLibLocaleZhCn); var _rcCalendarLibLocaleZhCn = __webpack_require__(134); var _rcCalendarLibLocaleZhCn2 = _interopRequireDefault(_rcCalendarLibLocaleZhCn); var _gregorianCalendarFormat = __webpack_require__(92); var _gregorianCalendarFormat2 = _interopRequireDefault(_gregorianCalendarFormat); // 和顶部文案保持一致 var _gregorianCalendarFormatLibLocaleZhCn = __webpack_require__(135); var _gregorianCalendarFormatLibLocaleZhCn2 = _interopRequireDefault(_gregorianCalendarFormatLibLocaleZhCn); _gregorianCalendarFormatLibLocaleZhCn2['default'].shortMonths = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']; // 以下两行代码 // 给没有初始值的日期选择框提供本地化信息 var defaultCalendarValue = new _gregorianCalendar2['default'](_gregorianCalendarLibLocaleZhCn2['default']); defaultCalendarValue.setTime(Date.now()); function createPicker(TheCalendar) { return _react2['default'].createClass({ getInitialState: function getInitialState() { var value = undefined; if (this.props.value) { value = new _gregorianCalendar2['default'](_gregorianCalendarLibLocaleZhCn2['default']); value.setTime(new Date(this.props.value).valueOf()); } return { value: value }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('value' in nextProps) { var value = null; if (nextProps.value) { value = new _gregorianCalendar2['default'](_gregorianCalendarLibLocaleZhCn2['default']); value.setTime(new Date(nextProps.value).valueOf()); } this.setState({ value: value }); } }, getDefaultProps: function getDefaultProps() { return { format: 'yyyy-MM-dd', placeholder: '请选择日期', transitionName: 'slide-up', onSelect: function onSelect() {} }; }, handleChange: function handleChange(v) { this.setState({ value: v }); this.props.onSelect(new Date(v.getTime())); }, render: function render() { var calendar = _react2['default'].createElement(TheCalendar, { disabledDate: this.props.disabledDate, locale: _rcCalendarLibLocaleZhCn2['default'], orient: ['top', 'left'], defaultValue: defaultCalendarValue, showTime: this.props.showTime, prefixCls: 'ant-calendar', showOk: this.props.showTime, showClear: false }); var sizeClass = ''; if (this.props.size === 'large') { sizeClass = ' ant-input-lg'; } else if (this.props.size === 'small') { sizeClass = ' ant-input-sm'; } var defaultValue = undefined; if (this.props.defaultValue) { defaultValue = new _gregorianCalendar2['default'](_gregorianCalendarLibLocaleZhCn2['default']); defaultValue.setTime(new Date(this.props.defaultValue).valueOf()); } return _react2['default'].createElement( _rcCalendar.Picker, { transitionName: this.props.transitionName, disabled: this.props.disabled, trigger: _react2['default'].createElement('span', { className: 'ant-calendar-picker-icon' }), calendar: calendar, adjustOrientOnCalendarOverflow: { x: true, y: false }, formatter: new _gregorianCalendarFormat2['default'](this.props.format), value: this.state.value, defaultValue: defaultValue, prefixCls: 'ant-calendar-picker', style: this.props.style, onChange: this.handleChange }, _react2['default'].createElement('input', { placeholder: this.props.placeholder, className: 'ant-calendar-picker-input ant-input' + sizeClass }) ); } }); } var AntDatePicker = createPicker(_rcCalendar2['default']); var AntMonthPicker = createPicker(_rcCalendar.MonthCalendar); var AntCalendar = _react2['default'].createClass({ displayName: 'AntCalendar', getDefaultProps: function getDefaultProps() { return { locale: _rcCalendarLibLocaleZhCn2['default'], prefixCls: 'ant-calendar' }; }, render: function render() { return _react2['default'].createElement(_rcCalendar2['default'], this.props); } }); AntDatePicker.Calendar = AntCalendar; AntDatePicker.MonthPicker = AntMonthPicker; exports['default'] = AntDatePicker; module.exports = exports['default']; /***/ }, /* 90 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Calendar = __webpack_require__(91); var _Calendar2 = _interopRequireDefault(_Calendar); var _Picker = __webpack_require__(113); var _Picker2 = _interopRequireDefault(_Picker); var _MonthCalendar = __webpack_require__(132); var _MonthCalendar2 = _interopRequireDefault(_MonthCalendar); _Calendar2['default'].Picker = _Picker2['default']; _Calendar2['default'].MonthCalendar = _MonthCalendar2['default']; exports['default'] = _Calendar2['default']; module.exports = exports['default']; /***/ }, /* 91 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _gregorianCalendarFormat = __webpack_require__(92); var _gregorianCalendarFormat2 = _interopRequireDefault(_gregorianCalendarFormat); var _gregorianCalendar = __webpack_require__(94); var _gregorianCalendar2 = _interopRequireDefault(_gregorianCalendar); var _rcUtil = __webpack_require__(77); var _dateDateTable = __webpack_require__(100); var _dateDateTable2 = _interopRequireDefault(_dateDateTable); var _calendarCalendarHeader = __webpack_require__(104); var _calendarCalendarHeader2 = _interopRequireDefault(_calendarCalendarHeader); var _calendarCalendarFooter = __webpack_require__(108); var _calendarCalendarFooter2 = _interopRequireDefault(_calendarCalendarFooter); var _mixinCalendarMixin = __webpack_require__(111); var _mixinCalendarMixin2 = _interopRequireDefault(_mixinCalendarMixin); function noop() {} function goStartMonth() { var next = this.state.value.clone(); next.setDayOfMonth(1); this.setValue(next); } function goEndMonth() { var next = this.state.value.clone(); next.setDayOfMonth(next.getActualMaximum(_gregorianCalendar2['default'].MONTH)); this.setValue(next); } function goMonth(direction) { var next = this.state.value.clone(); next.addMonth(direction); this.setValue(next); } function goYear(direction) { var next = this.state.value.clone(); next.addYear(direction); this.setValue(next); } function goWeek(direction) { var next = this.state.value.clone(); next.addWeekOfYear(direction); this.setValue(next); } function goDay(direction) { var next = this.state.value.clone(); next.addDayOfMonth(direction); this.setValue(next); } var Calendar = _react2['default'].createClass({ displayName: 'Calendar', mixins: [_mixinCalendarMixin2['default']], propTypes: { value: _react2['default'].PropTypes.object, defaultValue: _react2['default'].PropTypes.object, className: _react2['default'].PropTypes.string, orient: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.oneOf(['left', 'top', 'right', 'bottom'])), locale: _react2['default'].PropTypes.object, showWeekNumber: _react2['default'].PropTypes.bool, style: _react2['default'].PropTypes.object, showToday: _react2['default'].PropTypes.bool, visible: _react2['default'].PropTypes.bool, showTime: _react2['default'].PropTypes.bool, onSelect: _react2['default'].PropTypes.func, onOk: _react2['default'].PropTypes.func, prefixCls: _react2['default'].PropTypes.string, onKeyDown: _react2['default'].PropTypes.func, onClear: _react2['default'].PropTypes.func, onChange: _react2['default'].PropTypes.func, onFocus: _react2['default'].PropTypes.func, onBlur: _react2['default'].PropTypes.func }, getDefaultProps: function getDefaultProps() { return { showToday: true, onClear: noop, onOk: noop }; }, getInitialState: function getInitialState() { var props = this.props; this.dateFormatter = new _gregorianCalendarFormat2['default'](props.locale.dateFormat); var orient = props.orient; // bind methods this.nextMonth = goMonth.bind(this, 1); this.previousMonth = goMonth.bind(this, -1); this.nextYear = goYear.bind(this, 1); this.previousYear = goYear.bind(this, -1); return { orient: orient }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if (nextProps.orient) { this.setState({ orient: nextProps.orient }); } if (nextProps.locale !== this.props.locale) { this.dateFormatter = new _gregorianCalendarFormat2['default'](nextProps.locale.dateFormat); } }, onKeyDown: function onKeyDown(e) { var keyCode = e.keyCode; // mac var ctrlKey = e.ctrlKey || e.metaKey; switch (keyCode) { case _rcUtil.KeyCode.DOWN: goWeek.call(this, 1); e.preventDefault(); return 1; case _rcUtil.KeyCode.UP: goWeek.call(this, -1); e.preventDefault(); return 1; case _rcUtil.KeyCode.LEFT: if (ctrlKey) { this.previousYear(); } else { goDay.call(this, -1); } e.preventDefault(); return 1; case _rcUtil.KeyCode.RIGHT: if (ctrlKey) { this.nextYear(); } else { goDay.call(this, 1); } e.preventDefault(); return 1; case _rcUtil.KeyCode.HOME: goStartMonth.call(this); e.preventDefault(); return 1; case _rcUtil.KeyCode.END: goEndMonth.call(this); e.preventDefault(); return 1; case _rcUtil.KeyCode.PAGE_DOWN: this.nextMonth(); e.preventDefault(); return 1; case _rcUtil.KeyCode.PAGE_UP: this.previousMonth(); e.preventDefault(); return 1; case _rcUtil.KeyCode.ENTER: this.onSelect(this.state.value); e.preventDefault(); return 1; default: this.props.onKeyDown(e); return 1; } }, onClear: function onClear() { this.props.onClear(); }, onOk: function onOk() { this.props.onOk(this.state.value); }, render: function render() { var props = this.props; var locale = props.locale; var state = this.state; var value = state.value; var prefixCls = props.prefixCls; var children = _react2['default'].createElement( 'div', { style: { outline: 'none' } }, _react2['default'].createElement(_calendarCalendarHeader2['default'], { locale: locale, onValueChange: this.setValue, previousYear: this.previousYear, previousMonth: this.previousMonth, nextMonth: this.nextMonth, nextYear: this.nextYear, value: value, prefixCls: prefixCls }), _react2['default'].createElement( 'div', { className: prefixCls + '-calendar-body' }, _react2['default'].createElement(_dateDateTable2['default'], { locale: locale, value: value, prefixCls: prefixCls, dateRender: props.dateRender, onSelect: this.onSelect, disabledDate: props.disabledDate, showWeekNumber: props.showWeekNumber, dateFormatter: this.dateFormatter }) ), _react2['default'].createElement(_calendarCalendarFooter2['default'], { locale: locale, showClear: props.showClear, showOk: props.showOk, prefixCls: prefixCls, showToday: props.showToday, showTime: props.showTime, value: value, disabledDate: props.disabledDate, dateFormatter: this.dateFormatter, onClear: this.onClear, onOk: this.onOk, onSelect: this.onSelect, onToday: this.chooseToday }) ); return this.renderRoot({ children: children, className: props.showWeekNumber ? prefixCls + '-week-number' : '' }); }, chooseToday: function chooseToday() { var today = this.state.value.clone(); today.setTime(Date.now()); this.onSelect(today); } }); exports['default'] = Calendar; module.exports = exports['default']; /***/ }, /* 92 */ /***/ function(module, exports, __webpack_require__) { module.exports = __webpack_require__(93); /***/ }, /* 93 */ /***/ function(module, exports, __webpack_require__) { /** * @ignore * DateTimeFormat for * Inspired by DateTimeFormat from JDK. * @author yiminghe@gmail.com */ var GregorianCalendar = __webpack_require__(94); var enUsLocale = __webpack_require__(99); var MAX_VALUE = Number.MAX_VALUE; /** * date or time style enum * @enum {Number} Date.Formatter.Style */ var DateTimeStyle = { /** * full style */ FULL: 0, /** * long style */ LONG: 1, /** * medium style */ MEDIUM: 2, /** * short style */ SHORT: 3 }; /* Letter Date or Time Component Presentation Examples G Era designator Text AD y Year Year 1996; 96 M Month in year Month July; Jul; 07 w Week in year Number 27 W Week in month Number 2 D Day in year Number 189 d Day in month Number 10 F Day of week in month Number 2 E Day in week Text Tuesday; Tue a Am/pm marker Text PM H Hour in day (0-23) Number 0 k Hour in day (1-24) Number 24 K Hour in am/pm (0-11) Number 0 h Hour in am/pm (1-12) Number 12 m Minute in hour Number 30 s Second in minute Number 55 S Millisecond Number 978 x z Time zone General time zone Pacific Standard Time; PST; GMT-08:00 Z Time zone RFC 822 time zone -0800 */ var patternChars = new Array(GregorianCalendar.DAY_OF_WEEK_IN_MONTH + 2).join('1'); var ERA = 0; var calendarIndexMap = {}; patternChars = patternChars.split(''); patternChars[ERA] = 'G'; patternChars[GregorianCalendar.YEAR] = 'y'; patternChars[GregorianCalendar.MONTH] = 'M'; patternChars[GregorianCalendar.DAY_OF_MONTH] = 'd'; patternChars[GregorianCalendar.HOUR_OF_DAY] = 'H'; patternChars[GregorianCalendar.MINUTES] = 'm'; patternChars[GregorianCalendar.SECONDS] = 's'; patternChars[GregorianCalendar.MILLISECONDS] = 'S'; patternChars[GregorianCalendar.WEEK_OF_YEAR] = 'w'; patternChars[GregorianCalendar.WEEK_OF_MONTH] = 'W'; patternChars[GregorianCalendar.DAY_OF_YEAR] = 'D'; patternChars[GregorianCalendar.DAY_OF_WEEK_IN_MONTH] = 'F'; (function () { for (var index in patternChars) { calendarIndexMap[patternChars[index]] = index; } })(); function mix(t, s) { for (var p in s) { t[p] = s[p]; } } var SUBSTITUTE_REG = /\\?\{([^{}]+)\}/g; var EMPTY = ''; function substitute(str, o, regexp) { if (typeof str !== 'string' || !o) { return str; } return str.replace(regexp || SUBSTITUTE_REG, function (match, name) { if (match.charAt(0) === '\\') { return match.slice(1); } return (o[name] === undefined) ? EMPTY : o[name]; }); } patternChars = patternChars.join('') + 'ahkKZE'; function encode(lastField, count, compiledPattern) { compiledPattern.push({ field: lastField, count: count }); } function compile(pattern) { var length = pattern.length; var inQuote = false; var compiledPattern = []; var tmpBuffer = null; var count = 0; var lastField = -1; for (var i = 0; i < length; i++) { var c = pattern.charAt(i); if (c === '\'') { // '' is treated as a single quote regardless of being // in a quoted section. if ((i + 1) < length) { c = pattern.charAt(i + 1); if (c === '\'') { i++; if (count !== 0) { encode(lastField, count, compiledPattern); lastField = -1; count = 0; } if (inQuote) { tmpBuffer += c; } continue; } } if (!inQuote) { if (count !== 0) { encode(lastField, count, compiledPattern); lastField = -1; count = 0; } tmpBuffer = ''; inQuote = true; } else { compiledPattern.push({ text: tmpBuffer }); inQuote = false; } continue; } if (inQuote) { tmpBuffer += c; continue; } if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) { if (count !== 0) { encode(lastField, count, compiledPattern); lastField = -1; count = 0; } compiledPattern.push({ text: c }); continue; } if (patternChars.indexOf(c) === -1) { throw new Error('Illegal pattern character "' + c + '"'); } if (lastField === -1 || lastField === c) { lastField = c; count++; continue; } encode(lastField, count, compiledPattern); lastField = c; count = 1; } if (inQuote) { throw new Error('Unterminated quote'); } if (count !== 0) { encode(lastField, count, compiledPattern); } return compiledPattern; } var zeroDigit = '0'; // TODO zeroDigit localization?? function zeroPaddingNumber(value, minDigits, maxDigits, buffer) { // Optimization for 1, 2 and 4 digit numbers. This should // cover most cases of formatting date/time related items. // Note: This optimization code assumes that maxDigits is // either 2 or Integer.MAX_VALUE (maxIntCount in format()). buffer = buffer || []; maxDigits = maxDigits || MAX_VALUE; if (value >= 0) { if (value < 100 && minDigits >= 1 && minDigits <= 2) { if (value < 10 && minDigits === 2) { buffer.push(zeroDigit); } buffer.push(value); return buffer.join(''); } else if (value >= 1000 && value < 10000) { if (minDigits === 4) { buffer.push(value); return buffer.join(''); } if (minDigits === 2 && maxDigits === 2) { return zeroPaddingNumber(value % 100, 2, 2, buffer); } } } buffer.push(value + ''); return buffer.join(''); } /** * * date time formatter for GregorianCalendar * * @example * * var calendar = new GregorianCalendar(2013,9,24); * // ' to escape * var formatter = new GregorianCalendarFormat("'today is' ''yyyy/MM/dd a''"); * document.write(formatter.format(calendar)); * * @class GregorianCalendarFormat * @param {String} pattern patter string of date formatter * * <table border="1"> * <thead valign="bottom"> * <tr><th class="head">Letter</th> * <th class="head">Date or Time Component</th> * <th class="head">Presentation</th> * <th class="head">Examples</th> * </tr> * </thead> * <tbody valign="top"> * <tr><td>G</td> * <td>Era designator</td> * <td>Text</td> * <td>AD</td> * </tr> * <tr><td>y</td> * <td>Year</td> * <td>Year</td> * <td>1996; 96</td> * </tr> * <tr><td>M</td> * <td>Month in year</td> * <td>Month</td> * <td>July; Jul; 07</td> * </tr> * <tr><td>w</td> * <td>Week in year</td> * <td>Number</td> * <td>27</td> * </tr> * <tr><td>W</td> * <td>Week in month</td> * <td>Number</td> * <td>2</td> * </tr> * <tr><td>D</td> * <td>Day in year</td> * <td>Number</td> * <td>189</td> * </tr> * <tr><td>d</td> * <td>Day in month</td> * <td>Number</td> * <td>10</td> * </tr> * <tr><td>F</td> * <td>Day of week in month</td> * <td>Number</td> * <td>2</td> * </tr> * <tr><td>E</td> * <td>Day in week</td> * <td>Text</td> * <td>Tuesday; Tue</td> * </tr> * <tr><td>a</td> * <td>Am/pm marker</td> * <td>Text</td> * <td>PM</td> * </tr> * <tr><td>H</td> * <td>Hour in day (0-23)</td> * <td>Number</td> * <td>0</td> * </tr> * <tr><td>k</td> * <td>Hour in day (1-24)</td> * <td>Number</td> * <td>24</td> * </tr> * <tr><td>K</td> * <td>Hour in am/pm (0-11)</td> * <td>Number</td> * <td>0</td> * </tr> * <tr><td>h</td> * <td>Hour in am/pm (1-12)</td> * <td>Number</td> * <td>12</td> * </tr> * <tr><td>m</td> * <td>Minute in hour</td> * <td>Number</td> * <td>30</td> * </tr> * <tr><td>s</td> * <td>Second in minute</td> * <td>Number</td> * <td>55</td> * </tr> * <tr><td>S</td> * <td>Millisecond</td> * <td>Number</td> * <td>978</td> * </tr> * <tr><td>x/z</td> * <td>Time zone</td> * <td>General time zone</td> * <td>Pacific Standard Time; PST; GMT-08:00</td> * </tr> * <tr><td>Z</td> * <td>Time zone</td> * <td>RFC 822 time zone</td> * <td>-0800</td> * </tr> * </tbody> * </table> * @param {Object} locale format locale */ function DateTimeFormat(pattern, locale) { this.locale = locale || enUsLocale; this.originalPattern = pattern; this.pattern = compile(pattern); } function formatField(field, count, locale, calendar) { var current, value; switch (field) { case 'G': value = calendar.getYear() > 0 ? 1 : 0; current = locale.eras[value]; break; case 'y': value = calendar.getYear(); if (value <= 0) { value = 1 - value; } current = (zeroPaddingNumber(value, 2, count !== 2 ? MAX_VALUE : 2)); break; case 'M': value = calendar.getMonth(); if (count >= 4) { current = locale.months[value]; } else if (count === 3) { current = locale.shortMonths[value]; } else { current = zeroPaddingNumber(value + 1, count); } break; case 'k': current = zeroPaddingNumber(calendar.getHourOfDay() || 24, count); break; case 'E': value = calendar.getDayOfWeek(); current = count >= 4 ? locale.weekdays[value] : locale.shortWeekdays[value]; break; case 'a': current = locale.ampms[calendar.getHourOfDay() >= 12 ? 1 : 0]; break; case 'h': current = zeroPaddingNumber(calendar. getHourOfDay() % 12 || 12, count); break; case 'K': current = zeroPaddingNumber(calendar. getHourOfDay() % 12, count); break; case 'Z': var offset = calendar.getTimezoneOffset(); var parts = [offset < 0 ? '-' : '+']; offset = Math.abs(offset); parts.push(zeroPaddingNumber(Math.floor(offset / 60) % 100, 2), zeroPaddingNumber(offset % 60, 2)); current = parts.join(''); break; default : // case 'd': // case 'H': // case 'm': // case 's': // case 'S': // case 'D': // case 'F': // case 'w': // case 'W': var index = calendarIndexMap[field]; value = calendar.get(index); current = zeroPaddingNumber(value, count); } return current; } function matchField(dateStr, startIndex, matches) { var matchedLen = -1; var index = -1; var i; var len = matches.length; for (i = 0; i < len; i++) { var m = matches[i]; var mLen = m.length; if (mLen > matchedLen && matchPartString(dateStr, startIndex, m, mLen)) { matchedLen = mLen; index = i; } } return index >= 0 ? { value: index, startIndex: startIndex + matchedLen } : null; } function matchPartString(dateStr, startIndex, match, mLen) { for (var i = 0; i < mLen; i++) { if (dateStr.charAt(startIndex + i) !== match.charAt(i)) { return false; } } return true; } function getLeadingNumberLen(str) { var i, c; var len = str.length; for (i = 0; i < len; i++) { c = str.charAt(i); if (c < '0' || c > '9') { break; } } return i; } function matchNumber(dateStr, startIndex, count, obeyCount) { var str = dateStr; var n; if (obeyCount) { if (dateStr.length <= startIndex + count) { return null; } str = dateStr.slice(startIndex, startIndex + count); if (!str.match(/^\d+$/)) { throw new Error('GregorianCalendarFormat parse error, dateStr: ' + dateStr + ', patter: ' + (this.originalPattern)); } } else { str = str.slice(startIndex); } n = parseInt(str, 10); if (isNaN(n)) { throw new Error('GregorianCalendarFormat parse error, dateStr: ' + dateStr + ', patter: ' + (this.originalPattern)); } return { value: n, startIndex: startIndex + getLeadingNumberLen(str) }; } function parseField(calendar, dateStr, startIndex, field, count, obeyCount, tmp) { var match, year, hour; if (dateStr.length <= startIndex) { return startIndex; } var locale = this.locale; switch (field) { case 'G': if ((match = matchField(dateStr, startIndex, locale.eras))) { if (calendar.isSetYear()) { if (match.value === 0) { year = calendar.getYear(); calendar.setYear(1 - year); } } else { tmp.era = match.value; } } break; case 'y': if ((match = matchNumber.call(this, dateStr, startIndex, count, obeyCount))) { year = match.value; if ('era' in tmp) { if (tmp.era === 0) { year = 1 - year; } } calendar.setYear(year); } break; case 'M': var month; if (count >= 3) { if ((match = matchField(dateStr, startIndex, locale[count === 3 ? 'shortMonths' : 'months']))) { month = match.value; } } else { if ((match = matchNumber.call(this, dateStr, startIndex, count, obeyCount))) { month = match.value - 1; } } if (match) { calendar.setMonth(month); } break; case 'k': if ((match = matchNumber.call(this, dateStr, startIndex, count, obeyCount))) { calendar.setHourOfDay(match.value % 24); } break; case 'E': if ((match = matchField(dateStr, startIndex, locale[count > 3 ? 'weekdays' : 'shortWeekdays']))) { calendar.setDayOfWeek(match.value); } break; case 'a': if ((match = matchField(dateStr, startIndex, locale.ampms))) { if (calendar.isSetHourOfDay()) { if (match.value) { hour = calendar.getHourOfDay(); if (hour < 12) { calendar.setHourOfDay((hour + 12) % 24); } } } else { tmp.ampm = match.value; } } break; case 'h': if ((match = matchNumber.call(this, dateStr, startIndex, count, obeyCount))) { hour = match.value %= 12; if (tmp.ampm) { hour += 12; } calendar.setHourOfDay(hour); } break; case 'K': if ((match = matchNumber.call(this, dateStr, startIndex, count, obeyCount))) { hour = match.value; if (tmp.ampm) { hour += 12; } calendar.setHourOfDay(hour); } break; case 'Z': var sign = 1; var zoneChar = dateStr.charAt(startIndex); if (zoneChar === '-') { sign = -1; startIndex++; } else if (zoneChar === '+') { startIndex++; } else { break; } if ((match = matchNumber.call(this, dateStr, startIndex, 2, true))) { var zoneOffset = match.value * 60; startIndex = match.startIndex; if ((match = matchNumber.call(this, dateStr, startIndex, 2, true))) { zoneOffset += match.value; } calendar.setTimezoneOffset(zoneOffset); } break; default : // case 'd': // case 'H': // case 'm': // case 's': // case 'S': // case 'D': // case 'F': // case 'w': // case 'W' if ((match = matchNumber.call(this, dateStr, startIndex, count, obeyCount))) { var index = calendarIndexMap[field]; calendar.set(index, match.value); } } if (match) { startIndex = match.startIndex; } return startIndex; } mix(DateTimeFormat.prototype, { /** * format a GregorianDate instance according to specified pattern * @param {GregorianCalendar} calendar GregorianDate instance * @returns {string} formatted string of GregorianDate instance */ format: function (calendar) { if (!calendar.isGregorianCalendar) { throw new Error('calendar must be type of GregorianCalendar'); } var i; var ret = []; var pattern = this.pattern; var len = pattern.length; for (i = 0; i < len; i++) { var comp = pattern[i]; if (comp.text) { ret.push(comp.text); } else if ('field' in comp) { ret.push(formatField(comp.field, comp.count, this.locale, calendar)); } } return ret.join(''); }, /** * parse a formatted string of GregorianDate instance according to specified pattern * @param {String} dateStr formatted string of GregorianDate * @returns {GregorianCalendar} */ parse: function (dateStr, calendarLocale) { var calendar = new GregorianCalendar(calendarLocale); var i; var j; var tmp = {}; var obeyCount = false; var dateStrLen = dateStr.length; var errorIndex = -1; var startIndex = 0; var oldStartIndex = 0; var pattern = this.pattern; var len = pattern.length; loopPattern: { for (i = 0; errorIndex < 0 && i < len; i++) { var comp = pattern[i], text, textLen; oldStartIndex = startIndex; if ((text = comp.text)) { textLen = text.length; if ((textLen + startIndex) > dateStrLen) { errorIndex = startIndex; } else { for (j = 0; j < textLen; j++) { if (text.charAt(j) !== dateStr.charAt(j + startIndex)) { errorIndex = startIndex; break loopPattern; } } startIndex += textLen; } } else if ('field' in comp) { obeyCount = false; var nextComp = pattern[i + 1]; if (nextComp) { if ('field' in nextComp) { obeyCount = true; } else { var c = nextComp.text.charAt(0); if (c >= '0' && c <= '9') { obeyCount = true; } } } startIndex = parseField.call(this, calendar, dateStr, startIndex, comp.field, comp.count, obeyCount, tmp); if (startIndex === oldStartIndex) { errorIndex = startIndex; } } } } if (errorIndex >= 0) { console.error('error when parsing date'); console.error(dateStr); console.error(dateStr.slice(0, errorIndex) + '^'); return undefined; } return calendar; } }); mix(DateTimeFormat, { Style: DateTimeStyle, /** * get a formatter instance of short style pattern. * en-us: M/d/yy h:mm a * zh-cn: yy-M-d ah:mm * @param {Object} locale locale object * @returns {GregorianCalendar} * @static */ getInstance: function (locale) { return this.getDateTimeInstance(DateTimeStyle.SHORT, DateTimeStyle.SHORT, locale); }, /** * get a formatter instance of specified date style. * @param {Date.Formatter.Style} dateStyle date format style * @param {Object} locale * @returns {GregorianCalendar} * @static */ getDateInstance: function (dateStyle, locale) { return this.getDateTimeInstance(dateStyle, undefined, locale); }, /** * get a formatter instance of specified date style and time style. * @param {Date.Formatter.Style} dateStyle date format style * @param {Date.Formatter.Style} timeStyle time format style * @param {Object} locale * @returns {GregorianCalendar} * @static */ getDateTimeInstance: function (dateStyle, timeStyle, locale) { locale = locale || enUsLocale; var datePattern = ''; if (dateStyle !== undefined) { datePattern = locale.datePatterns[dateStyle]; } var timePattern = ''; if (timeStyle !== undefined) { timePattern = locale.timePatterns[timeStyle]; } var pattern = datePattern; if (timePattern) { if (datePattern) { pattern = substitute(locale.dateTimePattern, { date: datePattern, time: timePattern }); } else { pattern = timePattern; } } return new DateTimeFormat(pattern, locale); }, /** * get a formatter instance of specified time style. * @param {Date.Formatter.Style} timeStyle time format style * @param {Object} locale * @returns {GregorianCalendar} * @static */ getTimeInstance: function (timeStyle, locale) { return this.getDateTimeInstance(undefined, timeStyle, locale); } }); module.exports = DateTimeFormat; DateTimeFormat.version = '@VERSION@'; // gc_format@163.com /***/ }, /* 94 */ /***/ function(module, exports, __webpack_require__) { module.exports = __webpack_require__(95); /***/ }, /* 95 */ /***/ function(module, exports, __webpack_require__) { /** * GregorianCalendar class * @ignore * @author yiminghe@gmail.com */ var toInt = parseInt; var Utils = __webpack_require__(96); var defaultLocale = __webpack_require__(98); var Const = __webpack_require__(97); /** * GregorianCalendar class. * * - no arguments: * Constructs a default GregorianCalendar using the current time * in the default time zone with the default locale. * - one argument locale: * Constructs a GregorianCalendar * based on the current time in the default time zone with the given locale. * * @class Date.Gregorian */ function GregorianCalendar(locale) { locale = locale || defaultLocale; this.locale = locale; this.fields = []; /** * The currently set time for this date. * @protected * @type Number|undefined */ this.time = undefined; /** * The timezoneOffset in minutes used by this date. * @type Number * @protected */ this.timezoneOffset = locale.timezoneOffset; /** * The first day of the week * @type Number * @protected */ this.firstDayOfWeek = locale.firstDayOfWeek; /** * The number of days required for the first week in a month or year, * with possible values from 1 to 7. * @@protected * @type Number */ this.minimalDaysInFirstWeek = locale.minimalDaysInFirstWeek; this.fieldsComputed = false; } Utils.mix(GregorianCalendar, Const); Utils.mix(GregorianCalendar, { Utils: Utils, defaultLocale: defaultLocale, /** * Determines if the given year is a leap year. * Returns true if the given year is a leap year. To specify BC year numbers, * 1 - year number must be given. For example, year BC 4 is specified as -3. * @param {Number} year the given year. * @returns {Boolean} true if the given year is a leap year; false otherwise. * @static * @method */ isLeapYear: Utils.isLeapYear, /** * Enum indicating year field of date * @type Number */ YEAR: 1, /** * Enum indicating month field of date * @type Number */ MONTH: 2, /** * Enum indicating the day of the month * @type Number */ DAY_OF_MONTH: 3, /** * Enum indicating the hour (24). * @type Number */ HOUR_OF_DAY: 4, /** * Enum indicating the minute of the day * @type Number */ MINUTES: 5, /** * Enum indicating the second of the day * @type Number */ SECONDS: 6, /** * Enum indicating the millisecond of the day * @type Number */ MILLISECONDS: 7, /** * Enum indicating the week number within the current year * @type Number */ WEEK_OF_YEAR: 8, /** * Enum indicating the week number within the current month * @type Number */ WEEK_OF_MONTH: 9, /** * Enum indicating the day of the day number within the current year * @type Number */ DAY_OF_YEAR: 10, /** * Enum indicating the day of the week * @type Number */ DAY_OF_WEEK: 11, /** * Enum indicating the day of the ordinal number of the day of the week * @type Number */ DAY_OF_WEEK_IN_MONTH: 12, /** * Enum indicating am * @type Number */ AM: 0, /** * Enum indicating pm * @type Number */ PM: 1 }); var fields = ['', 'Year', 'Month', 'DayOfMonth', 'HourOfDay', 'Minutes', 'Seconds', 'Milliseconds', 'WeekOfYear', 'WeekOfMonth', 'DayOfYear', 'DayOfWeek', 'DayOfWeekInMonth' ]; var YEAR = GregorianCalendar.YEAR; var MONTH = GregorianCalendar.MONTH; var DAY_OF_MONTH = GregorianCalendar.DAY_OF_MONTH; var HOUR_OF_DAY = GregorianCalendar.HOUR_OF_DAY; var MINUTE = GregorianCalendar.MINUTES; var SECONDS = GregorianCalendar.SECONDS; var MILLISECONDS = GregorianCalendar.MILLISECONDS; var DAY_OF_WEEK_IN_MONTH = GregorianCalendar.DAY_OF_WEEK_IN_MONTH; var DAY_OF_YEAR = GregorianCalendar.DAY_OF_YEAR; var DAY_OF_WEEK = GregorianCalendar.DAY_OF_WEEK; var WEEK_OF_MONTH = GregorianCalendar.WEEK_OF_MONTH; var WEEK_OF_YEAR = GregorianCalendar.WEEK_OF_YEAR; var MONTH_LENGTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // 0-based var LEAP_MONTH_LENGTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // 0-based var ONE_SECOND = 1000; var ONE_MINUTE = 60 * ONE_SECOND; var ONE_HOUR = 60 * ONE_MINUTE; var ONE_DAY = 24 * ONE_HOUR; var ONE_WEEK = ONE_DAY * 7; var EPOCH_OFFSET = 719163; // Fixed date of January 1, 1970 (Gregorian) var mod = Utils.mod, isLeapYear = Utils.isLeapYear, floorDivide = Math.floor; var MIN_VALUES = [ undefined, 1, // YEAR GregorianCalendar.JANUARY, // MONTH 1, // DAY_OF_MONTH 0, // HOUR_OF_DAY 0, // MINUTE 0, // SECONDS 0, // MILLISECONDS 1, // WEEK_OF_YEAR undefined, // WEEK_OF_MONTH 1, // DAY_OF_YEAR GregorianCalendar.SUNDAY, // DAY_OF_WEEK 1 // DAY_OF_WEEK_IN_MONTH ]; var MAX_VALUES = [ undefined, 292278994, // YEAR GregorianCalendar.DECEMBER, // MONTH undefined, // DAY_OF_MONTH 23, // HOUR_OF_DAY 59, // MINUTE 59, // SECONDS 999, // MILLISECONDS undefined, // WEEK_OF_YEAR undefined, // WEEK_OF_MONTH undefined, // DAY_OF_YEAR GregorianCalendar.SATURDAY, // DAY_OF_WEEK undefined // DAY_OF_WEEK_IN_MONTH ]; GregorianCalendar.prototype = { constructor: GregorianCalendar, isGregorianCalendar: 1, /** * Determines if current year is a leap year. * Returns true if the given year is a leap year. To specify BC year numbers, * 1 - year number must be given. For example, year BC 4 is specified as -3. * @returns {Boolean} true if the given year is a leap year; false otherwise. * @method * @member Date.Gregorian */ isLeapYear: function () { return isLeapYear(this.getYear()); }, /** * Return local info for current date instance * @returns {Object} */ getLocale: function () { return this.locale; }, /** * Returns the minimum value for * the given calendar field of this GregorianCalendar instance. * The minimum value is defined as the smallest value * returned by the get method for any possible time value, * taking into consideration the current values of the getFirstDayOfWeek, * getMinimalDaysInFirstWeek. * @param field the calendar field. * @returns {Number} the minimum value for the given calendar field. */ getActualMinimum: function (field) { if (MIN_VALUES[field] !== undefined) { return MIN_VALUES[field]; } var fields = this.fields; if (field === WEEK_OF_MONTH) { var cal = this.clone(); cal.clear(); cal.set(fields[YEAR], fields[MONTH], 1); return cal.get(WEEK_OF_MONTH); } throw new Error('minimum value not defined!'); }, /** * Returns the maximum value for the given calendar field * of this GregorianCalendar instance. * The maximum value is defined as the largest value returned * by the get method for any possible time value, taking into consideration * the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek methods. * @param field the calendar field. * @returns {Number} the maximum value for the given calendar field. */ getActualMaximum: function (field) { if (MAX_VALUES[field] !== undefined) { return MAX_VALUES[field]; } var value, fields = this.fields; switch (field) { case DAY_OF_MONTH: value = getMonthLength(fields[YEAR], fields[MONTH]); break; case WEEK_OF_YEAR: var endOfYear = this.clone(); endOfYear.clear(); endOfYear.set(fields[YEAR], GregorianCalendar.DECEMBER, 31); value = endOfYear.get(WEEK_OF_YEAR); if (value === 1) { value = 52; } break; case WEEK_OF_MONTH: var endOfMonth = this.clone(); endOfMonth.clear(); endOfMonth.set(fields[YEAR], fields[MONTH], getMonthLength(fields[YEAR], fields[MONTH])); value = endOfMonth.get(WEEK_OF_MONTH); break; case DAY_OF_YEAR: value = getYearLength(fields[YEAR]); break; case DAY_OF_WEEK_IN_MONTH: value = toInt((getMonthLength(fields[YEAR], fields[MONTH]) - 1) / 7) + 1; break; } if (value === undefined) { throw new Error('maximum value not defined!'); } return value; }, /** * Determines if the given calendar field has a value set, * including cases that the value has been set by internal fields calculations * triggered by a get method call. * @param field the calendar field to be cleared. * @returns {boolean} true if the given calendar field has a value set; false otherwise. */ isSet: function (field) { return this.fields[field] !== undefined; }, /** * Converts the time value (millisecond offset from the Epoch) * to calendar field values. * @protected */ computeFields: function () { var time = this.time; var timezoneOffset = this.timezoneOffset * ONE_MINUTE; var fixedDate = toInt(timezoneOffset / ONE_DAY); var timeOfDay = timezoneOffset % ONE_DAY; fixedDate += toInt(time / ONE_DAY); timeOfDay += time % ONE_DAY; if (timeOfDay >= ONE_DAY) { timeOfDay -= ONE_DAY; fixedDate++; } else { while (timeOfDay < 0) { timeOfDay += ONE_DAY; fixedDate--; } } fixedDate += EPOCH_OFFSET; var date = Utils.getGregorianDateFromFixedDate(fixedDate); var year = date.year; var fields = this.fields; fields[YEAR] = year; fields[MONTH] = date.month; fields[DAY_OF_MONTH] = date.dayOfMonth; fields[DAY_OF_WEEK] = date.dayOfWeek; if (timeOfDay !== 0) { fields[HOUR_OF_DAY] = toInt(timeOfDay / ONE_HOUR); var r = timeOfDay % ONE_HOUR; fields[MINUTE] = toInt(r / ONE_MINUTE); r %= ONE_MINUTE; fields[SECONDS] = toInt(r / ONE_SECOND); fields[MILLISECONDS] = r % ONE_SECOND; } else { fields[HOUR_OF_DAY] = fields[MINUTE] = fields[SECONDS] = fields[MILLISECONDS] = 0; } var fixedDateJan1 = Utils.getFixedDate(year, GregorianCalendar.JANUARY, 1); var dayOfYear = fixedDate - fixedDateJan1 + 1; var fixDateMonth1 = fixedDate - date.dayOfMonth + 1; fields[DAY_OF_YEAR] = dayOfYear; fields[DAY_OF_WEEK_IN_MONTH] = toInt((date.dayOfMonth - 1) / 7) + 1; var weekOfYear = getWeekNumber(this, fixedDateJan1, fixedDate); // 本周没有足够的时间在当前年 if (weekOfYear === 0) { // If the date belongs to the last week of the // previous year, use the week number of "12/31" of // the "previous" year. var fixedDec31 = fixedDateJan1 - 1; var prevJan1 = fixedDateJan1 - getYearLength(year - 1); weekOfYear = getWeekNumber(this, prevJan1, fixedDec31); } else // 本周是年末最后一周,可能有足够的时间在新的一年 if (weekOfYear >= 52) { var nextJan1 = fixedDateJan1 + getYearLength(year); var nextJan1st = getDayOfWeekDateOnOrBefore(nextJan1 + 6, this.firstDayOfWeek); var nDays = nextJan1st - nextJan1; // 本周有足够天数在新的一年 if (nDays >= this.minimalDaysInFirstWeek && // 当天确实在本周,weekOfYear === 53 时是不需要这个判断 fixedDate >= (nextJan1st - 7) ) { weekOfYear = 1; } } fields[WEEK_OF_YEAR] = weekOfYear; fields[WEEK_OF_MONTH] = getWeekNumber(this, fixDateMonth1, fixedDate); this.fieldsComputed = true; }, /** * Converts calendar field values to the time value * (millisecond offset from the Epoch). * @protected */ computeTime: function () { if (!this.isSet(YEAR)) { throw new Error('year must be set for GregorianCalendar'); } var fields = this.fields; var year = fields[YEAR]; var timeOfDay = 0; if (this.isSet(HOUR_OF_DAY)) { timeOfDay += fields[HOUR_OF_DAY]; } timeOfDay *= 60; timeOfDay += fields[MINUTE] || 0; timeOfDay *= 60; timeOfDay += fields[SECONDS] || 0; timeOfDay *= 1000; timeOfDay += fields[MILLISECONDS] || 0; var fixedDate = 0; fields[YEAR] = year; fixedDate = fixedDate + this.getFixedDate(); // millis represents local wall-clock time in milliseconds. var millis = (fixedDate - EPOCH_OFFSET) * ONE_DAY + timeOfDay; millis -= this.timezoneOffset * ONE_MINUTE; this.time = millis; this.computeFields(); }, /** * Fills in any unset fields in the calendar fields. First, * the computeTime() method is called if the time value (millisecond offset from the Epoch) * has not been calculated from calendar field values. * Then, the computeFields() method is called to calculate all calendar field values. * @protected */ complete: function () { if (this.time === undefined) { this.computeTime(); } if (!this.fieldsComputed) { this.computeFields(); } }, getFixedDate: function () { var self = this; var fields = self.fields; var firstDayOfWeekCfg = self.firstDayOfWeek; var year = fields[YEAR]; var month = GregorianCalendar.JANUARY; if (self.isSet(MONTH)) { month = fields[MONTH]; if (month > GregorianCalendar.DECEMBER) { year += toInt(month / 12); month %= 12; } else if (month < GregorianCalendar.JANUARY) { year += floorDivide(month / 12); month = mod(month, 12); } } // Get the fixed date since Jan 1, 1 (Gregorian). We are on // the first day of either `month' or January in 'year'. var fixedDate = Utils.getFixedDate(year, month, 1); var firstDayOfWeek; var dayOfWeek = self.firstDayOfWeek; if (self.isSet(DAY_OF_WEEK)) { dayOfWeek = fields[DAY_OF_WEEK]; } if (self.isSet(MONTH)) { if (self.isSet(DAY_OF_MONTH)) { fixedDate += fields[DAY_OF_MONTH] - 1; } else { if (self.isSet(WEEK_OF_MONTH)) { firstDayOfWeek = getDayOfWeekDateOnOrBefore(fixedDate + 6, firstDayOfWeekCfg); // If we have enough days in the first week, then // move to the previous week. if ((firstDayOfWeek - fixedDate) >= self.minimalDaysInFirstWeek) { firstDayOfWeek -= 7; } if (dayOfWeek !== firstDayOfWeekCfg) { firstDayOfWeek = getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6, dayOfWeek); } fixedDate = firstDayOfWeek + 7 * (fields[WEEK_OF_MONTH] - 1); } else { var dowim; if (self.isSet(DAY_OF_WEEK_IN_MONTH)) { dowim = fields[DAY_OF_WEEK_IN_MONTH]; } else { dowim = 1; } var lastDate = (7 * dowim); if (dowim < 0) { lastDate = getMonthLength(year, month) + (7 * (dowim + 1)); } fixedDate = getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1, dayOfWeek); } } } else { // We are on the first day of the year. if (self.isSet(DAY_OF_YEAR)) { fixedDate += fields[DAY_OF_YEAR] - 1; } else { firstDayOfWeek = getDayOfWeekDateOnOrBefore(fixedDate + 6, firstDayOfWeekCfg); // If we have enough days in the first week, then move // to the previous week. if ((firstDayOfWeek - fixedDate) >= self.minimalDaysInFirstWeek) { firstDayOfWeek -= 7; } if (dayOfWeek !== firstDayOfWeekCfg) { firstDayOfWeek = getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6, dayOfWeek); } fixedDate = firstDayOfWeek + 7 * (fields[WEEK_OF_YEAR] - 1); } } return fixedDate; }, /** * Returns this Calendar's time value in milliseconds * @member Date.Gregorian * @returns {Number} the current time as UTC milliseconds from the epoch. */ getTime: function () { if (this.time === undefined) { this.computeTime(); } return this.time; }, /** * Sets this Calendar's current time from the given long value. * @param time the new time in UTC milliseconds from the epoch. */ setTime: function (time) { this.time = time; this.fieldsComputed = false; this.complete(); }, /** * Returns the value of the given calendar field. * @param field the given calendar field. * @returns {Number} the value for the given calendar field. */ get: function (field) { this.complete(); return this.fields[field]; }, /** * Returns the year of the given calendar field. * @method getYear * @returns {Number} the year for the given calendar field. */ /** * Returns the month of the given calendar field. * @method getMonth * @returns {Number} the month for the given calendar field. */ /** * Returns the day of month of the given calendar field. * @method getDayOfMonth * @returns {Number} the day of month for the given calendar field. */ /** * Returns the hour of day of the given calendar field. * @method getHourOfDay * @returns {Number} the hour of day for the given calendar field. */ /** * Returns the minute of the given calendar field. * @method getMinute * @returns {Number} the minute for the given calendar field. */ /** * Returns the second of the given calendar field. * @method getSecond * @returns {Number} the second for the given calendar field. */ /** * Returns the millisecond of the given calendar field. * @method getMilliSecond * @returns {Number} the millisecond for the given calendar field. */ /** * Returns the week of year of the given calendar field. * @method getWeekOfYear * @returns {Number} the week of year for the given calendar field. */ /** * Returns the week of month of the given calendar field. * @method getWeekOfMonth * @returns {Number} the week of month for the given calendar field. */ /** * Returns the day of year of the given calendar field. * @method getDayOfYear * @returns {Number} the day of year for the given calendar field. */ /** * Returns the day of week of the given calendar field. * @method getDayOfWeek * @returns {Number} the day of week for the given calendar field. */ /** * Returns the day of week in month of the given calendar field. * @method getDayOfWeekInMonth * @returns {Number} the day of week in month for the given calendar field. */ /** * Sets the given calendar field to the given value. * @param field the given calendar field. * @param v the value to be set for the given calendar field. */ set: function (field, v) { var len = arguments.length; if (len === 2) { this.fields[field] = v; } else if (len < MILLISECONDS + 1) { for (var i = 0; i < len; i++) { this.fields[YEAR + i] = arguments[i]; } } else { throw new Error('illegal arguments for GregorianCalendar set'); } this.time = undefined; }, /** * Set the year of the given calendar field. * @method setYear */ /** * Set the month of the given calendar field. * @method setMonth */ /** * Set the day of month of the given calendar field. * @method setDayOfMonth */ /** * Set the hour of day of the given calendar field. * @method setHourOfDay */ /** * Set the minute of the given calendar field. * @method setMinute */ /** * Set the second of the given calendar field. * @method setSecond */ /** * Set the millisecond of the given calendar field. * @method setMilliSecond */ /** * Set the week of year of the given calendar field. * @method setWeekOfYear */ /** * Set the week of month of the given calendar field. * @method setWeekOfMonth */ /** * Set the day of year of the given calendar field. * @method setDayOfYear */ /** * Set the day of week of the given calendar field. * @method setDayOfWeek */ /** * Set the day of week in month of the given calendar field. * @method setDayOfWeekInMonth */ /** * add for specified field based on two rules: * * - Add rule 1. The value of field after the call minus the value of field before the * call is amount, modulo any overflow that has occurred in field * Overflow occurs when a field value exceeds its range and, * as a result, the next larger field is incremented or * decremented and the field value is adjusted back into its range. * * - Add rule 2. If a smaller field is expected to be invariant, * but it is impossible for it to be equal to its * prior value because of changes in its minimum or maximum after * field is changed, then its value is adjusted to be as close * as possible to its expected value. A smaller field represents a * smaller unit of time. HOUR_OF_DAY is a smaller field than * DAY_OF_MONTH. No adjustment is made to smaller fields * that are not expected to be invariant. The calendar system * determines what fields are expected to be invariant. * * * @example * use('date/gregorian',function(S, GregorianCalendar){ * var d = new GregorianCalendar(); * d.set(2012, GregorianCalendar.JANUARY, 31); * d.add(Gregorian.MONTH,1); * // 2012-2-29 * document.writeln('<p>'+d.getYear()+'-'+d.getMonth()+'-'+d.getDayOfWeek()) * d.add(Gregorian.MONTH,12); * // 2013-2-28 * document.writeln('<p>'+d.getYear()+'-'+d.getMonth()+'-'+d.getDayOfWeek()) * }); * * @param field the calendar field. * @param {Number} amount he amount of date or time to be added to the field. */ add: function (field, amount) { if (!amount) { return; } var self = this; var fields = self.fields; // computer and retrieve original value var value = self.get(field); if (field === YEAR) { value += amount; self.set(YEAR, value); adjustDayOfMonth(self); } else if (field === MONTH) { value += amount; var yearAmount = floorDivide(value / 12); value = mod(value, 12); if (yearAmount) { self.set(YEAR, fields[YEAR] + yearAmount); } self.set(MONTH, value); adjustDayOfMonth(self); } else { switch (field) { case HOUR_OF_DAY: amount *= ONE_HOUR; break; case MINUTE: amount *= ONE_MINUTE; break; case SECONDS: amount *= ONE_SECOND; break; case MILLISECONDS: break; case WEEK_OF_MONTH: case WEEK_OF_YEAR: case DAY_OF_WEEK_IN_MONTH: amount *= ONE_WEEK; break; case DAY_OF_WEEK: case DAY_OF_YEAR: case DAY_OF_MONTH: amount *= ONE_DAY; break; default: throw new Error('illegal field for add'); } self.setTime(self.time + amount); } }, /** * add the year of the given calendar field. * @method addYear * @param {Number} amount the signed amount to add to field. */ /** * add the month of the given calendar field. * @method addMonth * @param {Number} amount the signed amount to add to field. */ /** * add the day of month of the given calendar field. * @method addDayOfMonth * @param {Number} amount the signed amount to add to field. */ /** * add the hour of day of the given calendar field. * @method addHourOfDay * @param {Number} amount the signed amount to add to field. */ /** * add the minute of the given calendar field. * @method addMinute * @param {Number} amount the signed amount to add to field. */ /** * add the second of the given calendar field. * @method addSecond * @param {Number} amount the signed amount to add to field. */ /** * add the millisecond of the given calendar field. * @method addMilliSecond * @param {Number} amount the signed amount to add to field. */ /** * add the week of year of the given calendar field. * @method addWeekOfYear * @param {Number} amount the signed amount to add to field. */ /** * add the week of month of the given calendar field. * @method addWeekOfMonth * @param {Number} amount the signed amount to add to field. */ /** * add the day of year of the given calendar field. * @method addDayOfYear * @param {Number} amount the signed amount to add to field. */ /** * add the day of week of the given calendar field. * @method addDayOfWeek * @param {Number} amount the signed amount to add to field. */ /** * add the day of week in month of the given calendar field. * @method addDayOfWeekInMonth * @param {Number} amount the signed amount to add to field. */ /** * Get rolled value for the field * @protected */ getRolledValue: function (value, amount, min, max) { var diff = value - min; var range = max - min + 1; amount %= range; return min + (diff + amount + range) % range; }, /** * Adds a signed amount to the specified calendar field without changing larger fields. * A negative roll amount means to subtract from field without changing * larger fields. If the specified amount is 0, this method performs nothing. * * * * @example * var d = new GregorianCalendar(); * d.set(1999, GregorianCalendar.AUGUST, 31); * // 1999-4-30 * // Tuesday June 1, 1999 * d.set(1999, GregorianCalendar.JUNE, 1); * d.add(Gregorian.WEEK_OF_MONTH,-1); // === d.add(Gregorian.WEEK_OF_MONTH, * d.get(Gregorian.WEEK_OF_MONTH)); * // 1999-06-29 * * * @param field the calendar field. * @param {Number} amount the signed amount to add to field. */ roll: function (field, amount) { if (!amount) { return; } var self = this; // computer and retrieve original value var value = self.get(field); var min = self.getActualMinimum(field); var max = self.getActualMaximum(field); value = self.getRolledValue(value, amount, min, max); self.set(field, value); // consider compute time priority switch (field) { case MONTH: adjustDayOfMonth(self); break; default: // other fields are set already when get self.updateFieldsBySet(field); break; } }, /** * roll the year of the given calendar field. * @method rollYear * @param {Number} amount the signed amount to add to field. */ /** * roll the month of the given calendar field. * @param {Number} amount the signed amount to add to field. * @method rollMonth */ /** * roll the day of month of the given calendar field. * @method rollDayOfMonth * @param {Number} amount the signed amount to add to field. */ /** * roll the hour of day of the given calendar field. * @method rollHourOfDay * @param {Number} amount the signed amount to add to field. */ /** * roll the minute of the given calendar field. * @method rollMinute * @param {Number} amount the signed amount to add to field. */ /** * roll the second of the given calendar field. * @method rollSecond * @param {Number} amount the signed amount to add to field. */ /** * roll the millisecond of the given calendar field. * @method rollMilliSecond * @param {Number} amount the signed amount to add to field. */ /** * roll the week of year of the given calendar field. * @method rollWeekOfYear * @param {Number} amount the signed amount to add to field. */ /** * roll the week of month of the given calendar field. * @method rollWeekOfMonth * @param {Number} amount the signed amount to add to field. */ /** * roll the day of year of the given calendar field. * @method rollDayOfYear * @param {Number} amount the signed amount to add to field. */ /** * roll the day of week of the given calendar field. * @method rollDayOfWeek * @param {Number} amount the signed amount to add to field. */ /** * remove other priority fields when call getFixedDate * precondition: other fields are all set or computed * @protected */ updateFieldsBySet: function (field) { var fields = this.fields; switch (field) { case WEEK_OF_MONTH: fields[DAY_OF_MONTH] = undefined; break; case DAY_OF_YEAR: fields[MONTH] = undefined; break; case DAY_OF_WEEK: fields[DAY_OF_MONTH] = undefined; break; case WEEK_OF_YEAR: fields[DAY_OF_YEAR] = undefined; fields[MONTH] = undefined; break; } }, /** * get current date instance's timezone offset * @returns {Number} */ getTimezoneOffset: function () { return this.timezoneOffset; }, /** * set current date instance's timezone offset */ setTimezoneOffset: function (timezoneOffset) { if (this.timezoneOffset !== timezoneOffset) { this.fieldsComputed = undefined; this.timezoneOffset = timezoneOffset; } }, /** * set first day of week for current date instance */ setFirstDayOfWeek: function (firstDayOfWeek) { if (this.firstDayOfWeek !== firstDayOfWeek) { this.firstDayOfWeek = firstDayOfWeek; this.fieldsComputed = false; } }, /** * Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France. * @returns {Number} the first day of the week. */ getFirstDayOfWeek: function () { return this.firstDayOfWeek; }, /** * Sets what the minimal days required in the first week of the year are; For example, * if the first week is defined as one that contains the first day of the first month of a year, * call this method with value 1. * If it must be a full week, use value 7. * @param minimalDaysInFirstWeek the given minimal days required in the first week of the year. */ setMinimalDaysInFirstWeek: function (minimalDaysInFirstWeek) { if (this.minimalDaysInFirstWeek !== minimalDaysInFirstWeek) { this.minimalDaysInFirstWeek = minimalDaysInFirstWeek; this.fieldsComputed = false; } }, /** * Gets what the minimal days required in the first week of the year are; e.g., * if the first week is defined as one that contains the first day of the first month of a year, * this method returns 1. * If the minimal days required must be a full week, this method returns 7. * @returns {Number} the minimal days required in the first week of the year. */ getMinimalDaysInFirstWeek: function () { return this.minimalDaysInFirstWeek; }, /** * Returns the number of weeks in the week year * represented by this GregorianCalendar. * * For example, if this GregorianCalendar's date is * December 31, 2008 with the ISO * 8601 compatible setting, this method will return 53 for the * period: December 29, 2008 to January 3, 2010 * while getActualMaximum(WEEK_OF_YEAR) will return * 52 for the period: December 31, 2007 to December 28, 2008. * * @return {Number} the number of weeks in the week year. */ getWeeksInWeekYear: function () { var weekYear = this.getWeekYear(); if (weekYear === this.get(YEAR)) { return this.getActualMaximum(WEEK_OF_YEAR); } // Use the 2nd week for calculating the max of WEEK_OF_YEAR var gc = this.clone(); gc.clear(); gc.setWeekDate(weekYear, 2, this.get(DAY_OF_WEEK)); return gc.getActualMaximum(WEEK_OF_YEAR); }, /** * Returns the week year represented by this GregorianCalendar. * The dates in the weeks between 1 and the * maximum week number of the week year have the same week year value * that may be one year before or after the calendar year value. * * @return {Number} the week year represented by this GregorianCalendar. */ getWeekYear: function () { var year = this.get(YEAR); // implicitly complete var weekOfYear = this.get(WEEK_OF_YEAR); var month = this.get(MONTH); if (month === GregorianCalendar.JANUARY) { if (weekOfYear >= 52) { --year; } } else if (month === GregorianCalendar.DECEMBER) { if (weekOfYear === 1) { ++year; } } return year; }, /** * Sets this GregorianCalendar to the date given by the date specifiers - weekYear, * weekOfYear, and dayOfWeek. weekOfYear follows the WEEK_OF_YEAR numbering. * The dayOfWeek value must be one of the DAY_OF_WEEK values: SUNDAY to SATURDAY. * * @param weekYear the week year * @param weekOfYear the week number based on weekYear * @param dayOfWeek the day of week value */ setWeekDate: function (weekYear, weekOfYear, dayOfWeek) { if (dayOfWeek < GregorianCalendar.SUNDAY || dayOfWeek > GregorianCalendar.SATURDAY) { throw new Error('invalid dayOfWeek: ' + dayOfWeek); } var fields = this.fields; // To avoid changing the time of day fields by date // calculations, use a clone with the GMT time zone. var gc = this.clone(); gc.clear(); gc.setTimezoneOffset(0); gc.set(YEAR, weekYear); gc.set(WEEK_OF_YEAR, 1); gc.set(DAY_OF_WEEK, this.getFirstDayOfWeek()); var days = dayOfWeek - this.getFirstDayOfWeek(); if (days < 0) { days += 7; } days += 7 * (weekOfYear - 1); if (days !== 0) { gc.add(DAY_OF_YEAR, days); } else { gc.complete(); } fields[YEAR] = gc.get(YEAR); fields[MONTH] = gc.get(MONTH); fields[DAY_OF_MONTH] = gc.get(DAY_OF_MONTH); this.complete(); }, /** * Creates and returns a copy of this object. * @returns {Date.Gregorian} */ clone: function () { if (this.time === undefined) { this.computeTime(); } var cal = new GregorianCalendar(this.locale); cal.setTimezoneOffset(cal.getTimezoneOffset()); cal.setFirstDayOfWeek(cal.getFirstDayOfWeek()); cal.setMinimalDaysInFirstWeek(cal.getMinimalDaysInFirstWeek()); cal.setTime(this.time); return cal; }, /** * Compares this GregorianCalendar to the specified Object. * The result is true if and only if the argument is a GregorianCalendar object * that represents the same time value (millisecond offset from the Epoch) * under the same Calendar parameters and Gregorian change date as this object. * @param {Date.Gregorian} obj the object to compare with. * @returns {boolean} true if this object is equal to obj; false otherwise. */ equals: function (obj) { return this.getTime() === obj.getTime() && this.firstDayOfWeek === obj.firstDayOfWeek && this.timezoneOffset === obj.timezoneOffset && this.minimalDaysInFirstWeek === obj.minimalDaysInFirstWeek; }, /** * Sets all the calendar field values or specified field and the time value * (millisecond offset from the Epoch) of this Calendar undefined. * This means that isSet() will return false for all the calendar fields, * and the date and time calculations will treat the fields as if they had never been set. * @param [field] the calendar field to be cleared. */ clear: function (field) { if (field === undefined) { this.field = []; } else { this.fields[field] = undefined; } this.time = undefined; this.fieldsComputed = false; } }; var GregorianCalendarProto = GregorianCalendar.prototype; Utils.each(fields, function (f, index) { if (f) { GregorianCalendarProto['get' + f] = function () { return this.get(index); }; GregorianCalendarProto['isSet' + f] = function () { return this.isSet(index); }; GregorianCalendarProto['set' + f] = function (v) { return this.set(index, v); }; GregorianCalendarProto['add' + f] = function (v) { return this.add(index, v); }; GregorianCalendarProto['roll' + f] = function (v) { return this.roll(index, v); }; } }); // ------------------- private start function adjustDayOfMonth(self) { var fields = self.fields; var year = fields[YEAR]; var month = fields[MONTH]; var monthLen = getMonthLength(year, month); var dayOfMonth = fields[DAY_OF_MONTH]; if (dayOfMonth > monthLen) { self.set(DAY_OF_MONTH, monthLen); } } function getMonthLength(year, month) { return isLeapYear(year) ? LEAP_MONTH_LENGTH[month] : MONTH_LENGTH[month]; } function getYearLength(year) { return isLeapYear(year) ? 366 : 365; } function getWeekNumber(self, fixedDay1, fixedDate) { var fixedDay1st = getDayOfWeekDateOnOrBefore(fixedDay1 + 6, self.firstDayOfWeek); var nDays = (fixedDay1st - fixedDay1); if (nDays >= self.minimalDaysInFirstWeek) { fixedDay1st -= 7; } var normalizedDayOfPeriod = (fixedDate - fixedDay1st); return floorDivide(normalizedDayOfPeriod / 7) + 1; } function getDayOfWeekDateOnOrBefore(fixedDate, dayOfWeek) { // 1.1.1 is monday // one week has 7 days return fixedDate - mod(fixedDate - dayOfWeek, 7); } // ------------------- private end module.exports = GregorianCalendar; /* http://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html TODO - day saving time - i18n - julian calendar */ /***/ }, /* 96 */ /***/ function(module, exports, __webpack_require__) { /** * utils for gregorian date * @ignore * @author yiminghe@gmail.com */ var Const = __webpack_require__(97); var floor = Math.floor; var ACCUMULATED_DAYS_IN_MONTH // 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 10/1 11/1 12/1 = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], ACCUMULATED_DAYS_IN_MONTH_LEAP // 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 // 10/1 11/1 12/1 = [0, 31, 59 + 1, 90 + 1, 120 + 1, 151 + 1, 181 + 1, 212 + 1, 243 + 1, 273 + 1, 304 + 1, 334 + 1], DAYS_OF_YEAR = 365, DAYS_OF_4YEAR = 365 * 4 + 1, DAYS_OF_100YEAR = DAYS_OF_4YEAR * 25 - 1, DAYS_OF_400YEAR = DAYS_OF_100YEAR * 4 + 1; function getDayOfYear(year, month, dayOfMonth) { return dayOfMonth + (exports.isLeapYear(year) ? ACCUMULATED_DAYS_IN_MONTH_LEAP[month] : ACCUMULATED_DAYS_IN_MONTH[month]); } function getDayOfWeekFromFixedDate(fixedDate) { // The fixed day 1 (January 1, 1 Gregorian) is Monday. if (fixedDate >= 0) { return fixedDate % 7; } return exports.mod(fixedDate, 7); } function getGregorianYearFromFixedDate(fixedDate) { var d0; var d1, d2, d3;//, d4; var n400, n100, n4, n1; var year; d0 = fixedDate - 1; n400 = floor(d0 / DAYS_OF_400YEAR); d1 = exports.mod(d0, DAYS_OF_400YEAR); n100 = floor(d1 / DAYS_OF_100YEAR); d2 = exports.mod(d1, DAYS_OF_100YEAR); n4 = floor(d2 / DAYS_OF_4YEAR); d3 = exports.mod(d2, DAYS_OF_4YEAR); n1 = floor(d3 / DAYS_OF_YEAR); year = 400 * n400 + 100 * n100 + 4 * n4 + n1; // ? if (!(n100 === 4 || n1 === 4)) { ++year; } return year; } var exports = module.exports = { each: function (arr, fn) { for (var i = 0, len = arr.length; i < len; i++) { if (fn(arr[i], i, arr) === false) { break; } } }, mix: function (t, s) { for (var p in s) { t[p] = s[p]; } }, isLeapYear: function (year) { if ((year & 3) !== 0) { return false; } return (year % 100 !== 0) || (year % 400 === 0); }, mod: function (x, y) { // 负数时不是镜像关系 return (x - y * floor(x / y)); }, // month: 0 based getFixedDate: function (year, month, dayOfMonth) { var prevYear = year - 1; // 考虑公元前 return DAYS_OF_YEAR * prevYear + floor(prevYear / 4) - floor(prevYear / 100) + floor(prevYear / 400) + getDayOfYear(year, month, dayOfMonth); }, getGregorianDateFromFixedDate: function (fixedDate) { var year = getGregorianYearFromFixedDate(fixedDate); var jan1 = exports.getFixedDate(year, Const.JANUARY, 1); var isLeap = exports.isLeapYear(year); var ACCUMULATED_DAYS = isLeap ? ACCUMULATED_DAYS_IN_MONTH_LEAP : ACCUMULATED_DAYS_IN_MONTH; var daysDiff = fixedDate - jan1; var month, i; for (i = 0; i < ACCUMULATED_DAYS.length; i++) { if (ACCUMULATED_DAYS[i] <= daysDiff) { month = i; } else { break; } } var dayOfMonth = fixedDate - jan1 - ACCUMULATED_DAYS[month] + 1; var dayOfWeek = getDayOfWeekFromFixedDate(fixedDate); return { year: year, month: month, dayOfMonth: dayOfMonth, dayOfWeek: dayOfWeek, isLeap: isLeap }; } }; /***/ }, /* 97 */ /***/ function(module, exports) { /** * @ignore * const for gregorian date * @author yiminghe@gmail.com */ module.exports = { /** * Enum indicating sunday * @type Number * @member Date.Gregorian */ SUNDAY: 0, /** * Enum indicating monday * @type Number * @member Date.Gregorian */ MONDAY: 1, /** * Enum indicating tuesday * @type Number * @member Date.Gregorian */ TUESDAY: 2, /** * Enum indicating wednesday * @type Number * @member Date.Gregorian */ WEDNESDAY: 3, /** * Enum indicating thursday * @type Number * @member Date.Gregorian */ THURSDAY: 4, /** * Enum indicating friday * @type Number * @member Date.Gregorian */ FRIDAY: 5, /** * Enum indicating saturday * @type Number * @member Date.Gregorian */ SATURDAY: 6, /** * Enum indicating january * @type Number * @member Date.Gregorian */ JANUARY: 0, /** * Enum indicating february * @type Number * @member Date.Gregorian */ FEBRUARY: 1, /** * Enum indicating march * @type Number * @member Date.Gregorian */ MARCH: 2, /** * Enum indicating april * @type Number * @member Date.Gregorian */ APRIL: 3, /** * Enum indicating may * @type Number * @member Date.Gregorian */ MAY: 4, /** * Enum indicating june * @type Number * @member Date.Gregorian */ JUNE: 5, /** * Enum indicating july * @type Number * @member Date.Gregorian */ JULY: 6, /** * Enum indicating august * @type Number * @member Date.Gregorian */ AUGUST: 7, /** * Enum indicating september * @type Number * @member Date.Gregorian */ SEPTEMBER: 8, /** * Enum indicating october * @type Number * @member Date.Gregorian */ OCTOBER: 9, /** * Enum indicating november * @type Number * @member Date.Gregorian */ NOVEMBER: 10, /** * Enum indicating december * @type Number * @member Date.Gregorian */ DECEMBER: 11 }; /***/ }, /* 98 */ /***/ function(module, exports) { /** * en-us locale * @ignore * @author yiminghe@gmail.com */ module.exports = { // in minutes timezoneOffset: -8 * 60, firstDayOfWeek: 0, minimalDaysInFirstWeek: 1 }; /***/ }, /* 99 */ /***/ function(module, exports) { /** * en-us locale * @ignore * @author yiminghe@gmail.com */ module.exports = { eras: ['BC', 'AD'], months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], shortWeekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], veryShortWeekdays: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], ampms: ['AM', 'PM'], datePatterns: ['EEEE, MMMM d, yyyy', 'MMMM d, yyyy', 'MMM d, yyyy', 'M/d/yy'], timePatterns: ['h:mm:ss a \'GMT\'Z', 'h:mm:ss a', 'h:mm:ss a', 'h:mm a'], dateTimePattern: '{date} {time}' }; /***/ }, /* 100 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _DateTHead = __webpack_require__(101); var _DateTHead2 = _interopRequireDefault(_DateTHead); var _DateTBody = __webpack_require__(103); var _DateTBody2 = _interopRequireDefault(_DateTBody); var DateTable = (function (_React$Component) { _inherits(DateTable, _React$Component); function DateTable() { _classCallCheck(this, DateTable); _get(Object.getPrototypeOf(DateTable.prototype), 'constructor', this).apply(this, arguments); } _createClass(DateTable, [{ key: 'render', value: function render() { var props = this.props; var prefixCls = props.prefixCls; return _react2['default'].createElement( 'table', { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' }, _react2['default'].createElement(_DateTHead2['default'], props), _react2['default'].createElement(_DateTBody2['default'], props) ); } }]); return DateTable; })(_react2['default'].Component); exports['default'] = DateTable; module.exports = exports['default']; /***/ }, /* 101 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _DateConstants = __webpack_require__(102); var _DateConstants2 = _interopRequireDefault(_DateConstants); var DateTHead = (function (_React$Component) { _inherits(DateTHead, _React$Component); function DateTHead() { _classCallCheck(this, DateTHead); _get(Object.getPrototypeOf(DateTHead.prototype), 'constructor', this).apply(this, arguments); } _createClass(DateTHead, [{ key: 'render', value: function render() { var props = this.props; var value = props.value; var locale = props.locale; var prefixCls = props.prefixCls; var veryShortWeekdays = []; var weekDays = []; var firstDayOfWeek = value.getFirstDayOfWeek(); var showWeekNumberEl = undefined; for (var i = 0; i < _DateConstants2['default'].DATE_COL_COUNT; i++) { var index = (firstDayOfWeek + i) % _DateConstants2['default'].DATE_COL_COUNT; veryShortWeekdays[i] = locale.format.veryShortWeekdays[index]; weekDays[i] = locale.format.weekdays[index]; } if (props.showWeekNumber) { showWeekNumberEl = _react2['default'].createElement( 'th', { role: 'columnheader', className: prefixCls + '-column-header ' + prefixCls + '-week-number-header' }, _react2['default'].createElement( 'span', { className: prefixCls + '-column-header-inner' }, 'x' ) ); } var weekDaysEls = weekDays.map(function (day, xindex) { return _react2['default'].createElement( 'th', { key: xindex, role: 'columnheader', title: day, className: prefixCls + '-column-header' }, _react2['default'].createElement( 'span', { className: prefixCls + '-column-header-inner' }, veryShortWeekdays[xindex] ) ); }); return _react2['default'].createElement( 'thead', null, _react2['default'].createElement( 'tr', { role: 'row' }, showWeekNumberEl, weekDaysEls ) ); } }]); return DateTHead; })(_react2['default'].Component); exports['default'] = DateTHead; module.exports = exports['default']; /***/ }, /* 102 */ /***/ function(module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = { DATE_ROW_COUNT: 6, DATE_COL_COUNT: 7 }; module.exports = exports["default"]; /***/ }, /* 103 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _DateConstants = __webpack_require__(102); var _DateConstants2 = _interopRequireDefault(_DateConstants); function isSameDay(one, two) { return one.getYear() === two.getYear() && one.getMonth() === two.getMonth() && one.getDayOfMonth() === two.getDayOfMonth(); } function beforeCurrentMonthYear(current, today) { if (current.getYear() < today.getYear()) { return 1; } return current.getYear() === today.getYear() && current.getMonth() < today.getMonth(); } function afterCurrentMonthYear(current, today) { if (current.getYear() > today.getYear()) { return 1; } return current.getYear() === today.getYear() && current.getMonth() > today.getMonth(); } function getIdFromDate(d) { return 'rc-calendar-' + d.getYear() + '-' + d.getMonth() + '-' + d.getDayOfMonth(); } function noop() {} function handleDayClick(current) { this.props.onSelect(current); } var DateTBody = (function (_React$Component) { _inherits(DateTBody, _React$Component); function DateTBody() { _classCallCheck(this, DateTBody); _get(Object.getPrototypeOf(DateTBody.prototype), 'constructor', this).apply(this, arguments); } _createClass(DateTBody, [{ key: 'render', value: function render() { var props = this.props; var i = undefined; var j = undefined; var current = undefined; var dateTable = []; var showWeekNumber = props.showWeekNumber; var value = props.value; var today = value.clone(); var prefixCls = props.prefixCls; var cellClass = prefixCls + '-cell'; var weekNumberCellClass = prefixCls + '-week-number-cell'; var dateClass = prefixCls + '-date'; var dateRender = props.dateRender; var disabledDate = props.disabledDate; var dateFormatter = this.props.dateFormatter; var todayClass = prefixCls + '-today'; var selectedClass = prefixCls + '-selected-day'; var lastMonthDayClass = prefixCls + '-last-month-cell'; var nextMonthDayClass = prefixCls + '-next-month-btn-day'; var disabledClass = prefixCls + '-disabled-cell'; var firstDisableClass = prefixCls + '-disabled-cell-first-of-row'; var lastDisableClass = prefixCls + '-disabled-cell-last-of-row'; today.setTime(Date.now()); var month1 = value.clone(); month1.set(value.getYear(), value.getMonth(), 1); var day = month1.getDayOfWeek(); var lastMonthDiffDay = (day + 7 - value.getFirstDayOfWeek()) % 7; // calculate last month var lastMonth1 = month1.clone(); lastMonth1.addDayOfMonth(0 - lastMonthDiffDay); var passed = 0; for (i = 0; i < _DateConstants2['default'].DATE_ROW_COUNT; i++) { for (j = 0; j < _DateConstants2['default'].DATE_COL_COUNT; j++) { current = lastMonth1; if (passed) { current = current.clone(); current.addDayOfMonth(passed); } dateTable.push(current); passed++; } } var tableHtml = []; passed = 0; for (i = 0; i < _DateConstants2['default'].DATE_ROW_COUNT; i++) { var weekNumberCell = undefined; var dateCells = []; if (showWeekNumber) { weekNumberCell = _react2['default'].createElement( 'td', { key: dateTable[passed].getWeekOfYear(), role: 'gridcell', className: weekNumberCellClass }, dateTable[passed].getWeekOfYear() ); } for (j = 0; j < _DateConstants2['default'].DATE_COL_COUNT; j++) { var next = null; var last = null; current = dateTable[passed]; if (j < _DateConstants2['default'].DATE_COL_COUNT - 1) { next = dateTable[passed + 1]; } if (j > 0) { last = dateTable[passed - 1]; } var cls = cellClass; var disabled = false; var selected = false; if (isSameDay(current, today)) { cls += ' ' + todayClass; } if (isSameDay(current, value)) { cls += ' ' + selectedClass; selected = true; } if (beforeCurrentMonthYear(current, value)) { cls += ' ' + lastMonthDayClass; } if (afterCurrentMonthYear(current, value)) { cls += ' ' + nextMonthDayClass; } if (disabledDate) { if (disabledDate(current, value)) { cls += ' ' + disabledClass; disabled = true; if (!last || !disabledDate(last, value)) { cls += ' ' + firstDisableClass; } if (!next || !disabledDate(next, value)) { cls += ' ' + lastDisableClass; } } } var dateHtml = undefined; if (dateRender) { dateHtml = dateRender(current, value); } else { dateHtml = _react2['default'].createElement( 'span', { key: getIdFromDate(current), className: dateClass, 'aria-selected': selected, 'aria-disabled': disabled }, current.getDayOfMonth() ); } dateCells.push(_react2['default'].createElement( 'td', { key: passed, onClick: disabled ? noop : handleDayClick.bind(this, current), role: 'gridcell', title: dateFormatter.format(current), className: cls }, dateHtml )); passed++; } tableHtml.push(_react2['default'].createElement( 'tr', { key: i, role: 'row' }, weekNumberCell, dateCells )); } return _react2['default'].createElement( 'tbody', { className: prefixCls + 'tbody' }, tableHtml ); } }]); return DateTBody; })(_react2['default'].Component); exports['default'] = DateTBody; DateTBody.propTypes = { dateFormatter: _react2['default'].PropTypes.object }; module.exports = exports['default']; /***/ }, /* 104 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _monthMonthPanel = __webpack_require__(105); var _monthMonthPanel2 = _interopRequireDefault(_monthMonthPanel); var _gregorianCalendarFormat = __webpack_require__(92); var _gregorianCalendarFormat2 = _interopRequireDefault(_gregorianCalendarFormat); var _yearYearPanel = __webpack_require__(106); var _yearYearPanel2 = _interopRequireDefault(_yearYearPanel); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); var toFragment = _rcUtil2['default'].Children.mapSelf; var CalendarHeader = (function (_React$Component) { _inherits(CalendarHeader, _React$Component); function CalendarHeader(props) { _classCallCheck(this, CalendarHeader); _get(Object.getPrototypeOf(CalendarHeader.prototype), 'constructor', this).call(this, props); this.state = {}; this.yearFormatter = new _gregorianCalendarFormat2['default'](props.locale.yearFormat); this.monthFormatter = new _gregorianCalendarFormat2['default'](props.locale.monthFormat); this.showMonthPanel = this.showMonthPanel.bind(this); this.showYearPanel = this.showYearPanel.bind(this); this.onSelect = this.onSelect.bind(this); } _createClass(CalendarHeader, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { var locale = this.props.locale; if (nextProps.locale !== locale) { this.yearFormatter = new _gregorianCalendarFormat2['default'](locale.yearFormat); this.monthFormatter = new _gregorianCalendarFormat2['default'](locale.monthFormat); } } }, { key: 'onSelect', value: function onSelect(value) { this.setState({ showMonthPanel: 0, showYearPanel: 0 }); this.props.onValueChange(value); } }, { key: 'getMonthYearElement', value: function getMonthYearElement() { var props = this.props; var prefixCls = props.prefixCls; var locale = props.locale; var value = this.props.value; var monthBeforeYear = locale.monthBeforeYear; var selectClassName = prefixCls + '-' + (monthBeforeYear ? 'my-select' : 'ym-select'); var year = _react2['default'].createElement( 'a', { className: prefixCls + '-year-select', role: 'button', onClick: this.showYearPanel, title: locale.monthSelect }, this.yearFormatter.format(value) ); var month = _react2['default'].createElement( 'a', { className: prefixCls + '-month-select', role: 'button', onClick: this.showMonthPanel, title: locale.monthSelect }, this.monthFormatter.format(value) ); var my = []; if (monthBeforeYear) { my = [month, year]; } else { my = [year, month]; } return _react2['default'].createElement( 'span', { className: selectClassName }, toFragment(my) ); } }, { key: 'render', value: function render() { var props = this.props; var state = this.state; var prefixCls = props.prefixCls; var locale = props.locale; var value = props.value; var PanelClass = null; if (state.showMonthPanel) { PanelClass = _monthMonthPanel2['default']; } else if (state.showYearPanel) { PanelClass = _yearYearPanel2['default']; } var panel = undefined; if (PanelClass) { panel = _react2['default'].createElement(PanelClass, { locale: locale, defaultValue: value, rootPrefixCls: prefixCls, onSelect: this.onSelect }); } return _react2['default'].createElement( 'div', { className: prefixCls + '-header' }, _react2['default'].createElement( 'a', { className: prefixCls + '-prev-year-btn', role: 'button', onClick: props.previousYear, title: locale.previousYear }, '«' ), _react2['default'].createElement( 'a', { className: prefixCls + '-prev-month-btn', role: 'button', onClick: props.previousMonth, title: locale.previousMonth }, '‹' ), this.getMonthYearElement(), _react2['default'].createElement( 'a', { className: prefixCls + '-next-month-btn', onClick: props.nextMonth, title: locale.nextMonth }, '›' ), _react2['default'].createElement( 'a', { className: prefixCls + '-next-year-btn', onClick: props.nextYear, title: locale.nextYear }, '»' ), panel ); } }, { key: 'showMonthPanel', value: function showMonthPanel() { this.setState({ showMonthPanel: 1, showYearPanel: 0 }); } }, { key: 'showYearPanel', value: function showYearPanel() { this.setState({ showMonthPanel: 0, showYearPanel: 1 }); } }]); return CalendarHeader; })(_react2['default'].Component); exports['default'] = CalendarHeader; CalendarHeader.propTypes = { locale: _react2['default'].PropTypes.object, value: _react2['default'].PropTypes.object, onValueChange: _react2['default'].PropTypes.func }; module.exports = exports['default']; /***/ }, /* 105 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _yearYearPanel = __webpack_require__(106); var _yearYearPanel2 = _interopRequireDefault(_yearYearPanel); var ROW = 4; var COL = 3; function goYear(direction) { var next = this.state.value.clone(); next.addYear(direction); this.setAndChangeValue(next); } function chooseMonth(month) { var next = this.state.value.clone(); next.setMonth(month); this.setAndSelectValue(next); } function noop() {} var MonthPanel = _react2['default'].createClass({ displayName: 'MonthPanel', propTypes: { onChange: _react2['default'].PropTypes.func, onSelect: _react2['default'].PropTypes.func }, getDefaultProps: function getDefaultProps() { return { onChange: noop, onSelect: noop }; }, getInitialState: function getInitialState() { var props = this.props; // bind methods this.nextYear = goYear.bind(this, 1); this.previousYear = goYear.bind(this, -1); this.prefixCls = props.rootPrefixCls + '-month-panel'; return { value: props.value || props.defaultValue }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('value' in nextProps) { this.setState({ value: nextProps.value }); } }, onYearPanelSelect: function onYearPanelSelect(current) { this.setState({ showYearPanel: 0 }); this.setAndChangeValue(current); }, getMonths: function getMonths() { var props = this.props; var value = this.state.value; var current = value.clone(); var locale = props.locale; var months = []; var shortMonths = locale.format.shortMonths; var index = 0; for (var i = 0; i < ROW; i++) { months[i] = []; for (var j = 0; j < COL; j++) { current.setMonth(index); months[i][j] = { value: index, content: shortMonths[index], title: shortMonths[index] }; index++; } } return months; }, render: function render() { var _this = this; var props = this.props; var value = this.state.value; var locale = props.locale; var months = this.getMonths(); var year = value.getYear(); var currentMonth = value.getMonth(); var prefixCls = this.prefixCls; var monthsEls = months.map(function (month, index) { var tds = month.map(function (m) { var _classNameMap; var disabled = false; if (props.disabledDate) { var testValue = value.clone(); testValue.setMonth(m.value); disabled = props.disabledDate(testValue); } var classNameMap = (_classNameMap = {}, _defineProperty(_classNameMap, prefixCls + '-cell', 1), _defineProperty(_classNameMap, prefixCls + '-cell-disabled', disabled), _defineProperty(_classNameMap, prefixCls + '-selected-cell', m.value === currentMonth), _classNameMap); return _react2['default'].createElement( 'td', { role: 'gridcell', key: m.value, onClick: disabled ? null : chooseMonth.bind(_this, m.value), title: m.title, className: (0, _rcUtil.classSet)(classNameMap) }, _react2['default'].createElement( 'a', { className: prefixCls + '-month' }, m.content ) ); }); return _react2['default'].createElement( 'tr', { key: index, role: 'row' }, tds ); }); var yearPanel = undefined; if (this.state.showYearPanel) { yearPanel = _react2['default'].createElement(_yearYearPanel2['default'], { locale: locale, value: value, rootPrefixCls: props.rootPrefixCls, onSelect: this.onYearPanelSelect }); } return _react2['default'].createElement( 'div', { className: prefixCls, style: props.style }, _react2['default'].createElement( 'div', null, _react2['default'].createElement( 'div', { className: prefixCls + '-header' }, _react2['default'].createElement( 'a', { className: prefixCls + '-prev-year-btn', role: 'button', onClick: this.previousYear, title: locale.previousYear }, '«' ), _react2['default'].createElement( 'a', { className: prefixCls + '-year-select', role: 'button', onClick: this.showYearPanel, title: locale.yearSelect }, _react2['default'].createElement( 'span', { className: prefixCls + '-year-select-content' }, year ), _react2['default'].createElement( 'span', { className: prefixCls + '-year-select-arrow' }, 'x' ) ), _react2['default'].createElement( 'a', { className: prefixCls + '-next-year-btn', role: 'button', onClick: this.nextYear, title: locale.nextYear }, '»' ) ), _react2['default'].createElement( 'div', { className: prefixCls + '-body' }, _react2['default'].createElement( 'table', { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' }, _react2['default'].createElement( 'tbody', { className: prefixCls + '-tbody' }, monthsEls ) ) ) ), yearPanel ); }, setAndChangeValue: function setAndChangeValue(value) { this.setValue(value); this.props.onChange(value); }, setAndSelectValue: function setAndSelectValue(value) { this.setValue(value); this.props.onSelect(value); }, setValue: function setValue(value) { if (!('value' in this.props)) { this.setState({ value: value }); } }, showYearPanel: function showYearPanel() { this.setState({ showYearPanel: 1 }); } }); exports['default'] = MonthPanel; module.exports = exports['default']; /***/ }, /* 106 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _decadeDecadePanel = __webpack_require__(107); var _decadeDecadePanel2 = _interopRequireDefault(_decadeDecadePanel); var ROW = 4; var COL = 3; function goYear(direction) { var next = this.state.value.clone(); next.addYear(direction); this.setState({ value: next }); } function chooseYear(year) { var next = this.state.value.clone(); next.setYear(year); this.props.onSelect(next); } var YearPanel = (function (_React$Component) { _inherits(YearPanel, _React$Component); function YearPanel(props) { var _this = this; _classCallCheck(this, YearPanel); _get(Object.getPrototypeOf(YearPanel.prototype), 'constructor', this).call(this, props); this.prefixCls = props.rootPrefixCls + '-year-panel'; this.state = { value: props.value || props.defaultValue }; this.nextDecade = goYear.bind(this, 10); this.previousDecade = goYear.bind(this, -10); ['showDecadePanel', 'onDecadePanelSelect'].forEach(function (m) { _this[m] = _this[m].bind(_this); }); } _createClass(YearPanel, [{ key: 'onDecadePanelSelect', value: function onDecadePanelSelect(current) { this.setState({ value: current, showDecadePanel: 0 }); } }, { key: 'getYears', value: function getYears() { var value = this.state.value; var currentYear = value.getYear(); var startYear = parseInt(currentYear / 10, 10) * 10; var previousYear = startYear - 1; var endYear = startYear + 9; var years = []; var index = 0; for (var i = 0; i < ROW; i++) { years[i] = []; for (var j = 0; j < COL; j++) { var year = previousYear + index; var content = undefined; if (year < startYear) { content = ''; } else if (year > endYear) { content = ''; } else { content = year + ''; } years[i][j] = { content: content, year: year, title: content }; index++; } } return years; } }, { key: 'render', value: function render() { var _this2 = this; var props = this.props; var value = this.state.value; var locale = props.locale; var years = this.getYears(); var currentYear = value.getYear(); var startYear = parseInt(currentYear / 10, 10) * 10; var endYear = startYear + 9; var prefixCls = this.prefixCls; var yeasEls = years.map(function (row, index) { var tds = row.map(function (y) { var _classNameMap; var classNameMap = (_classNameMap = {}, _defineProperty(_classNameMap, prefixCls + '-cell', 1), _defineProperty(_classNameMap, prefixCls + '-selected-cell', y.year === currentYear), _defineProperty(_classNameMap, prefixCls + '-last-decade-cell', y.year < startYear), _defineProperty(_classNameMap, prefixCls + '-next-decade-cell', y.year > endYear), _classNameMap); var clickHandler = undefined; if (y.year < startYear) { clickHandler = _this2.previousDecade; } else if (y.year > endYear) { clickHandler = _this2.nextDecade; } else { clickHandler = chooseYear.bind(_this2, y.year); } return _react2['default'].createElement( 'td', { role: 'gridcell', title: y.title, key: y.content, onClick: clickHandler, className: (0, _rcUtil.classSet)(classNameMap) }, _react2['default'].createElement( 'a', { className: prefixCls + '-year' }, y.content ) ); }); return _react2['default'].createElement( 'tr', { key: index, role: 'row' }, tds ); }); var decadePanel = undefined; if (this.state.showDecadePanel) { decadePanel = _react2['default'].createElement(_decadeDecadePanel2['default'], { locale: locale, value: value, rootPrefixCls: props.rootPrefixCls, onSelect: this.onDecadePanelSelect }); } return _react2['default'].createElement( 'div', { className: this.prefixCls }, _react2['default'].createElement( 'div', null, _react2['default'].createElement( 'div', { className: prefixCls + '-header' }, _react2['default'].createElement( 'a', { className: prefixCls + '-prev-decade-btn', role: 'button', onClick: this.previousDecade, title: locale.previousDecade }, '«' ), _react2['default'].createElement( 'a', { className: prefixCls + '-decade-select', role: 'button', onClick: this.showDecadePanel, title: locale.decadeSelect }, _react2['default'].createElement( 'span', { className: prefixCls + '-decade-select-content' }, startYear, '-', endYear ), _react2['default'].createElement( 'span', { className: prefixCls + '-decade-select-arrow' }, 'x' ) ), _react2['default'].createElement( 'a', { className: prefixCls + '-next-decade-btn', role: 'button', onClick: this.nextDecade, title: locale.nextDecade }, '»' ) ), _react2['default'].createElement( 'div', { className: prefixCls + '-body' }, _react2['default'].createElement( 'table', { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' }, _react2['default'].createElement( 'tbody', { className: prefixCls + '-tbody' }, yeasEls ) ) ) ), decadePanel ); } }, { key: 'showDecadePanel', value: function showDecadePanel() { this.setState({ showDecadePanel: 1 }); } }]); return YearPanel; })(_react2['default'].Component); exports['default'] = YearPanel; YearPanel.defaultProps = { onSelect: function onSelect() {} }; module.exports = exports['default']; /***/ }, /* 107 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var ROW = 4; var COL = 3; function goYear(direction) { var next = this.state.value.clone(); next.addYear(direction); this.setState({ value: next }); } function chooseDecade(year, e) { var next = this.state.value.clone(); next.setYear(year); this.props.onSelect(next); e.preventDefault(); } var DecadePanel = (function (_React$Component) { _inherits(DecadePanel, _React$Component); function DecadePanel(props) { _classCallCheck(this, DecadePanel); _get(Object.getPrototypeOf(DecadePanel.prototype), 'constructor', this).call(this, props); this.state = { value: props.value || props.defaultValue }; // bind methods this.prefixCls = props.rootPrefixCls + '-decade-panel'; this.nextCentury = goYear.bind(this, 100); this.previousCentury = goYear.bind(this, -100); } _createClass(DecadePanel, [{ key: 'render', value: function render() { var _this = this; var value = this.state.value; var locale = this.props.locale; var currentYear = value.getYear(); var startYear = parseInt(currentYear / 100, 10) * 100; var preYear = startYear - 10; var endYear = startYear + 99; var decades = []; var index = 0; var prefixCls = this.prefixCls; for (var i = 0; i < ROW; i++) { decades[i] = []; for (var j = 0; j < COL; j++) { var startDecade = preYear + index * 10; var endDecade = preYear + index * 10 + 9; decades[i][j] = { startDecade: startDecade, endDecade: endDecade }; index++; } } var decadesEls = decades.map(function (row, decadeIndex) { var tds = row.map(function (d) { var _classNameMap; var dStartDecade = d.startDecade; var dEndDecade = d.endDecade; var isLast = dStartDecade < startYear; var isNext = dEndDecade > endYear; var classNameMap = (_classNameMap = {}, _defineProperty(_classNameMap, prefixCls + '-cell', 1), _defineProperty(_classNameMap, prefixCls + '-selected-cell', dStartDecade <= currentYear && currentYear <= dEndDecade), _defineProperty(_classNameMap, prefixCls + '-last-century-cell', isLast), _defineProperty(_classNameMap, prefixCls + '-next-century-cell', isNext), _classNameMap); var content = undefined; var clickHandler = undefined; if (isLast) { clickHandler = _this.previousCentury; } else if (isNext) { clickHandler = _this.nextCentury; } else { content = dStartDecade + '-' + dEndDecade; clickHandler = chooseDecade.bind(_this, dStartDecade); } return _react2['default'].createElement( 'td', { key: dStartDecade, onClick: clickHandler, role: 'gridcell', className: (0, _rcUtil.classSet)(classNameMap) }, _react2['default'].createElement( 'a', { className: prefixCls + '-decade' }, content ) ); }); return _react2['default'].createElement( 'tr', { key: decadeIndex, role: 'row' }, tds ); }); return _react2['default'].createElement( 'div', { className: this.prefixCls }, _react2['default'].createElement( 'div', { className: prefixCls + '-header' }, _react2['default'].createElement( 'a', { className: prefixCls + '-prev-century-btn', role: 'button', onClick: this.previousCentury, title: locale.previousCentury }, '«' ), _react2['default'].createElement( 'div', { className: prefixCls + '-century' }, startYear, '-', endYear ), _react2['default'].createElement( 'a', { className: prefixCls + '-next-century-btn', role: 'button', onClick: this.nextCentury, title: locale.nextCentury }, '»' ) ), _react2['default'].createElement( 'div', { className: prefixCls + '-body' }, _react2['default'].createElement( 'table', { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' }, _react2['default'].createElement( 'tbody', { className: prefixCls + '-tbody' }, decadesEls ) ) ) ); } }]); return DecadePanel; })(_react2['default'].Component); exports['default'] = DecadePanel; DecadePanel.propTypes = { locale: _react2['default'].PropTypes.object }; DecadePanel.defaultProps = { onSelect: function onSelect() {} }; module.exports = exports['default']; /***/ }, /* 108 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _timeTime = __webpack_require__(109); var _timeTime2 = _interopRequireDefault(_timeTime); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); var toFragment = _rcUtil2['default'].Children.mapSelf; var CalendarFooter = (function (_React$Component) { _inherits(CalendarFooter, _React$Component); function CalendarFooter() { _classCallCheck(this, CalendarFooter); _get(Object.getPrototypeOf(CalendarFooter.prototype), 'constructor', this).apply(this, arguments); } _createClass(CalendarFooter, [{ key: 'getTodayTimeStr', value: function getTodayTimeStr() { var today = this.getTodayTime(); return this.props.dateFormatter.format(today); } }, { key: 'getTodayTime', value: function getTodayTime() { var value = this.props.value; var today = value.clone(); today.setTime(Date.now()); return today; } }, { key: 'render', value: function render() { var props = this.props; var value = props.value; var locale = props.locale; var prefixCls = props.prefixCls; var footerEl = null; if (props.showToday || props.showTime) { var nowEl = undefined; var localeNow = locale.today; if (props.showTime) { localeNow = locale.now || locale.today; } if (props.showToday) { var disabledToday = false; var disabledTodayClass = ''; if (props.disabledDate) { disabledToday = props.disabledDate(this.getTodayTime(), value); if (disabledToday) { disabledTodayClass = prefixCls + '-today-btn-disabled'; } } nowEl = _react2['default'].createElement( 'a', { className: prefixCls + '-today-btn ' + disabledTodayClass, role: 'button', onClick: disabledToday ? null : props.onToday, title: this.getTodayTimeStr() }, localeNow ); } var clearEl = undefined; if (props.showClear) { clearEl = _react2['default'].createElement( 'a', { className: prefixCls + '-clear-btn', role: 'button', onClick: props.onClear }, locale.clear ); } var okBtn = undefined; if (props.showOk) { okBtn = _react2['default'].createElement( 'a', { className: prefixCls + '-ok-btn', role: 'button', onClick: props.onOk }, locale.ok ); } var footerBtn = undefined; if (nowEl || clearEl) { footerBtn = _react2['default'].createElement( 'span', { className: prefixCls + '-footer-btn' }, toFragment([nowEl, okBtn, clearEl]) ); } var timeEl = undefined; if (props.showTime) { timeEl = _react2['default'].createElement(_timeTime2['default'], { value: value, prefixCls: prefixCls, locale: locale, onChange: props.onSelect }); } footerEl = _react2['default'].createElement( 'div', { className: prefixCls + '-footer' }, timeEl, footerBtn ); } return footerEl; } }]); return CalendarFooter; })(_react2['default'].Component); exports['default'] = CalendarFooter; module.exports = exports['default']; /***/ }, /* 109 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); var _TimePanel = __webpack_require__(110); var _TimePanel2 = _interopRequireDefault(_TimePanel); var setHourOfDay = 'setHourOfDay'; var setMinutes = 'setMinutes'; var setSeconds = 'setSeconds'; function padding(number) { var ret = number; if (ret < 10) { ret = '0' + ret; } return ret; } function loop(value, min, max) { var ret = value; if (ret === min - 1) { ret = max; } else if (ret === max + 1) { ret = min; } return ret; } function keyDownWrap(method, min, max) { return function onKeyDown(e) { var value = e.target.value; var number = parseInt(value, 10); var keyCode = e.keyCode; var handled = undefined; if (keyCode === _rcUtil.KeyCode.DOWN) { number++; e.stopPropagation(); e.preventDefault(); handled = 1; } else if (keyCode === _rcUtil.KeyCode.UP) { number--; e.stopPropagation(); e.preventDefault(); handled = 1; } if (handled) { number = loop(number, min, max); var time = this.props.value.clone(); time[method](number); this.props.onChange(time, e); } }; } var Time = (function (_React$Component) { _inherits(Time, _React$Component); function Time(props) { var _this = this; _classCallCheck(this, Time); _get(Object.getPrototypeOf(Time.prototype), 'constructor', this).call(this, props); this.state = { showHourPanel: 0, showMinutePanel: 0, showSecondPanel: 0 }; var events = ['onHourKeyDown', 'onMinuteKeyDown', 'onSecondKeyDown', 'onHourClick', 'onMinuteClick', 'onSecondClick', 'onSelectPanel']; events.forEach(function (m) { _this[m] = _this[m].bind(_this); }); } _createClass(Time, [{ key: 'shouldComponentUpdate', value: function shouldComponentUpdate() { return _rcUtil2['default'].PureRenderMixin.shouldComponentUpdate.apply(this, arguments); } }, { key: 'onSelectPanel', value: function onSelectPanel(value, setter) { var _this2 = this; this.setState({ showHourPanel: 0, showMinutePanel: 0, showSecondPanel: 0 }, function () { // ie9 has broken focus _react2['default'].findDOMNode(_this2.refs[setter]).focus(); }); this.props.onChange(value); } }, { key: 'onHourClick', value: function onHourClick() { this.setState({ showHourPanel: 1, showMinutePanel: 0, showSecondPanel: 0 }); } }, { key: 'onMinuteClick', value: function onMinuteClick() { this.setState({ showHourPanel: 0, showMinutePanel: 1, showSecondPanel: 0 }); } }, { key: 'onSecondClick', value: function onSecondClick() { this.setState({ showHourPanel: 0, showMinutePanel: 0, showSecondPanel: 1 }); } }, { key: 'render', value: function render() { var state = this.state; var props = this.props; var prefixCls = props.prefixCls; var value = props.value; var locale = props.locale; var hour = value.getHourOfDay(); var minute = value.getMinutes(); var second = value.getSeconds(); var panel = undefined; var commonProps = { value: value, onSelect: this.onSelectPanel, rootPrefixCls: prefixCls }; if (state.showHourPanel) { panel = _react2['default'].createElement(_TimePanel2['default'], _extends({ rowCount: 6, colCount: 4, getter: 'getHourOfDay', setter: setHourOfDay, title: locale.hourPanelTitle }, commonProps)); } else if (state.showMinutePanel) { panel = _react2['default'].createElement(_TimePanel2['default'], _extends({ rowCount: 6, colCount: 10, getter: 'getMinutes', setter: setMinutes, title: locale.minutePanelTitle }, commonProps)); } else if (state.showSecondPanel) { panel = _react2['default'].createElement(_TimePanel2['default'], _extends({ rowCount: 6, colCount: 10, getter: 'getSeconds', setter: setSeconds, title: locale.secondPanelTitle }, commonProps)); } return _react2['default'].createElement( 'span', { className: prefixCls + '-time' }, _react2['default'].createElement('input', { className: prefixCls + '-time-input', title: locale.hourInput, ref: setHourOfDay, readOnly: true, value: padding(hour), onClick: this.onHourClick, onKeyDown: this.onHourKeyDown }), _react2['default'].createElement( 'span', { className: prefixCls + '-time-minute' }, _react2['default'].createElement( 'span', null, ' : ' ), _react2['default'].createElement('input', { className: prefixCls + '-time-input', title: locale.minuteInput, ref: setMinutes, readOnly: true, value: padding(minute), onClick: this.onMinuteClick, onKeyDown: this.onMinuteKeyDown }) ), _react2['default'].createElement( 'span', { className: prefixCls + '-time-second' }, _react2['default'].createElement( 'span', null, ' : ' ), _react2['default'].createElement('input', { className: prefixCls + '-time-input', title: locale.secondInput, ref: setSeconds, readOnly: true, value: padding(second), onClick: this.onSecondClick, onKeyDown: this.onSecondKeyDown }) ), panel ); } }]); return Time; })(_react2['default'].Component); exports['default'] = Time; Time.prototype.onHourKeyDown = keyDownWrap('setHourOfDay', 0, 23); Time.prototype.onMinuteKeyDown = keyDownWrap('setMinutes', 0, 59); Time.prototype.onSecondKeyDown = keyDownWrap('setSeconds', 0, 59); Time.propTypes = { onChange: _react2['default'].PropTypes.func }; Time.defaultProps = { onChange: function onChange() {} }; module.exports = exports['default']; /***/ }, /* 110 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); function choose(hour, e) { var next = this.state.value.clone(); var method = this.props.setter; next[method](hour); this.props.onSelect(next, method); e.preventDefault(); } var TimePanel = (function (_React$Component) { _inherits(TimePanel, _React$Component); function TimePanel(props) { _classCallCheck(this, TimePanel); _get(Object.getPrototypeOf(TimePanel.prototype), 'constructor', this).call(this, props); this.state = { value: props.value }; this.prefixCls = props.rootPrefixCls + '-time-panel'; } _createClass(TimePanel, [{ key: 'render', value: function render() { var _this = this; var value = this.state.value; var props = this.props; var method = props.getter; var currentHour = value[method](); var data = []; var prefixCls = this.prefixCls; var ROW = props.rowCount; var COL = props.colCount; for (var i = 0; i < ROW; i++) { data[i] = []; for (var j = 0; j < COL; j++) { data[i][j] = i * COL + j; } } var hoursEls = data.map(function (row, index) { var tds = row.map(function (d) { var _classNameMap; var classNameMap = (_classNameMap = {}, _defineProperty(_classNameMap, prefixCls + '-cell', 1), _defineProperty(_classNameMap, prefixCls + '-selected-cell', d === currentHour), _classNameMap); return _react2['default'].createElement( 'td', { key: d, onClick: choose.bind(_this, d), role: 'gridcell', className: (0, _rcUtil.classSet)(classNameMap) }, _react2['default'].createElement( 'a', { className: prefixCls + '-time' }, d ) ); }); return _react2['default'].createElement( 'tr', { key: index, role: 'row' }, tds ); }); return _react2['default'].createElement( 'div', { className: prefixCls }, _react2['default'].createElement( 'div', { className: prefixCls + '-header' }, _react2['default'].createElement( 'div', { className: prefixCls + '-title' }, props.title ) ), _react2['default'].createElement( 'div', { className: prefixCls + '-body' }, _react2['default'].createElement( 'table', { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' }, _react2['default'].createElement( 'tbody', { className: prefixCls + '-tbody' }, hoursEls ) ) ) ); } }]); return TimePanel; })(_react2['default'].Component); exports['default'] = TimePanel; TimePanel.defaultProps = { onSelect: function onSelect() {} }; module.exports = exports['default']; /***/ }, /* 111 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _localeEnUs = __webpack_require__(112); var _localeEnUs2 = _interopRequireDefault(_localeEnUs); var _rcUtil = __webpack_require__(77); var _gregorianCalendar = __webpack_require__(94); var _gregorianCalendar2 = _interopRequireDefault(_gregorianCalendar); function noop() {} function getNow() { var value = new _gregorianCalendar2['default'](); value.setTime(Date.now()); return value; } function getNowByCurrentStateValue(value) { var ret = undefined; if (value) { ret = value.clone(); ret.setTime(Date.now()); } else { ret = getNow(); } return ret; } var CalendarMixin = { propTypes: { value: _react2['default'].PropTypes.object, defaultValue: _react2['default'].PropTypes.object, className: _react2['default'].PropTypes.string, orient: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.oneOf(['left', 'top', 'right', 'bottom'])), locale: _react2['default'].PropTypes.object, style: _react2['default'].PropTypes.object, visible: _react2['default'].PropTypes.bool, onSelect: _react2['default'].PropTypes.func, prefixCls: _react2['default'].PropTypes.string, onKeyDown: _react2['default'].PropTypes.func, onChange: _react2['default'].PropTypes.func, onFocus: _react2['default'].PropTypes.func, onBlur: _react2['default'].PropTypes.func }, getDefaultProps: function getDefaultProps() { return { locale: _localeEnUs2['default'], style: {}, visible: true, prefixCls: 'rc-calendar', className: '', onKeyDown: noop, onSelect: noop, onChange: noop, onFocus: noop, onBlur: noop }; }, getInitialState: function getInitialState() { var props = this.props; var value = props.value || props.defaultValue || getNow(); return { value: value }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var value = nextProps.value; if (value !== undefined) { value = value || nextProps.defaultValue || getNowByCurrentStateValue(this.state.value); this.setState({ value: value }); } }, shouldComponentUpdate: function shouldComponentUpdate(nextProps) { return this.props.visible || nextProps.visible; }, onSelect: function onSelect(value, keyDownEvent) { this.setValue(value); if (!keyDownEvent) { if (this.isAllowedDate(value)) { this.props.onSelect(value); } } }, onFocus: function onFocus() { if (this._blurTimer) { clearTimeout(this._blurTimer); this._blurTimer = null; } else { this.props.onFocus(); } }, onBlur: function onBlur() { var _this = this; if (this._blurTimer) { clearTimeout(this._blurTimer); } this._blurTimer = setTimeout(function () { _this.props.onBlur(); }, 100); }, renderRoot: function renderRoot(newProps) { var _className; var props = this.props; var state = this.state; var prefixCls = props.prefixCls; var className = (_className = {}, _defineProperty(_className, prefixCls, 1), _defineProperty(_className, prefixCls + '-hidden', !props.visible), _defineProperty(_className, props.className, !!props.className), _className); var orient = state.orient; if (orient) { orient.forEach(function (o) { className[prefixCls + '-orient-' + o] = 1; }); } return _react2['default'].createElement( 'div', { className: (0, _rcUtil.classSet)(className) + ' ' + newProps.className, style: this.props.style, tabIndex: '0', onFocus: this.onFocus, onBlur: this.onBlur, onKeyDown: this.onKeyDown }, newProps.children ); }, setValue: function setValue(value) { if (!('value' in this.props)) { this.setState({ value: value }); } this.props.onChange(value); }, isAllowedDate: function isAllowedDate(value) { var disabledDate = this.props.disabledDate; return !disabledDate || !disabledDate(value); }, setOrient: function setOrient(orient) { // FIXME: hack to prevent breaking rc-animate if (this.state.orient === orient) { return; } this.state.orient = orient; var prefixCls = this.props.prefixCls; var root = _react2['default'].findDOMNode(this); var className = root.className.replace(new RegExp(prefixCls + '-orient-\\w+', 'g'), ''); if (orient) { orient.forEach(function (o) { className += ' ' + prefixCls + '-orient-' + o; }); } root.className = className; } }; exports['default'] = CalendarMixin; module.exports = exports['default']; /***/ }, /* 112 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _gregorianCalendarFormatLibLocaleEnUs = __webpack_require__(99); var _gregorianCalendarFormatLibLocaleEnUs2 = _interopRequireDefault(_gregorianCalendarFormatLibLocaleEnUs); exports['default'] = { today: 'Today', now: 'Now', ok: 'Ok', clear: 'Clear', hourPanelTitle: 'Select hour', minutePanelTitle: 'Select minute', secondPanelTitle: 'Select second', monthSelect: 'Choose a month', yearSelect: 'Choose a year', decadeSelect: 'Choose a decade', yearFormat: 'yyyy', dateFormat: 'M/d/yyyy', monthFormat: 'MMMM', monthBeforeYear: true, previousMonth: 'Previous month (PageUp)', nextMonth: 'Next month (PageDown)', hourInput: 'Last hour(Up), Next hour(Down)', minuteInput: 'Last minute(Up), Next minute(Down)', secondInput: 'Last second(Up), Next second(Down)', previousYear: 'Last year (Control + left)', nextYear: 'Next year (Control + right)', previousDecade: 'Last decade', nextDecade: 'Next decade', previousCentury: 'Last century', nextCentury: 'Next century', format: _gregorianCalendarFormatLibLocaleEnUs2['default'] }; module.exports = exports['default']; /***/ }, /* 113 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _gregorianCalendarFormat = __webpack_require__(92); var _gregorianCalendarFormat2 = _interopRequireDefault(_gregorianCalendarFormat); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); var _rcAlign = __webpack_require__(114); var _rcAlign2 = _interopRequireDefault(_rcAlign); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var toFragment = _rcUtil2['default'].Children.mapSelf; var orientMap = { tl: ['top', 'left'], tr: ['top', 'right'], bl: ['bottom', 'left'], br: ['bottom', 'right'] }; function getImmutableOrient(orient) { if (orient) { for (var i in orientMap) { if (orientMap.hasOwnProperty(i)) { var original = orientMap[i]; if (original[0] === orient[0] && original[1] === orient[1]) { return original; } } } } } function prevent(e) { e.preventDefault(); } function noop() {} function refFn(field, component) { this[field] = component; } /** * DatePicker = wrap input using Calendar */ var Picker = _react2['default'].createClass({ displayName: 'Picker', propTypes: { onChange: _react2['default'].PropTypes.func, onOpen: _react2['default'].PropTypes.func, onClose: _react2['default'].PropTypes.func, calendar: _react2['default'].PropTypes.element, style: _react2['default'].PropTypes.object, open: _react2['default'].PropTypes.bool, defaultOpen: _react2['default'].PropTypes.bool, prefixCls: _react2['default'].PropTypes.string, adjustOrientOnCalendarOverflow: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.bool, _react2['default'].PropTypes.object]) }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-calendar-picker', adjustOrientOnCalendarOverflow: true, style: {}, defaultOpen: false, onChange: noop, onOpen: noop, onClose: noop, formatter: new _gregorianCalendarFormat2['default']('yyyy-MM-dd') }; }, getInitialState: function getInitialState() { var props = this.props; var open = undefined; if ('open' in props) { open = props.open; } else { open = props.defaultOpen; } var value = props.value || props.defaultValue; this.saveCalendarRef = refFn.bind(this, 'calendarInstance'); this.saveInputRef = refFn.bind(this, 'inputInstance'); return { open: open, value: value }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var value = nextProps.value; if (value !== undefined) { // null special meaning value = value || nextProps.defaultValue || null; this.setState({ value: value }); } if ('open' in nextProps) { this.setState({ open: nextProps.open }); } }, componentDidUpdate: function componentDidUpdate() { if (this.haveOpened) { _react2['default'].render(this.getCalendarElement(), this.getCalendarContainer()); } }, componentWillUnmount: function componentWillUnmount() { if (this.calendarContainer) { _react2['default'].unmountComponentAtNode(this.calendarContainer); this.calendarContainer.parentNode.removeChild(this.calendarContainer); this.calendarContainer = null; } }, onCalendarAlign: function onCalendarAlign(node, align) { var points = align.points; var newOrient = orientMap[points[0]]; this.calendarInstance.setOrient(newOrient); // focus after align _react2['default'].findDOMNode(this.calendarInstance).focus(); }, onInputClick: function onInputClick() { this.toggle(); }, onTriggerClick: function onTriggerClick() { this.toggle(); }, onKeyDown: function onKeyDown(e) { // down if (e.keyCode === _rcUtil.KeyCode.DOWN) { e.preventDefault(); this.open(); } }, onCalendarKeyDown: function onCalendarKeyDown(e) { if (e.keyCode === _rcUtil.KeyCode.ESC) { e.stopPropagation(); this.close(this.focusInput); } }, onCalendarSelect: function onCalendarSelect(value) { var currentValue = this.state.value; this.setState({ value: value }); if (!this.props.calendar.props.showTime) { this.close(this.focusInput); } if (!currentValue || currentValue.getTime() !== value.getTime()) { this.props.onChange(value); } }, onCalendarBlur: function onCalendarBlur() { if (document.activeElement === this.getInputDOMNode()) { return; } // if invisible, will not trigger blur // do not set if already false, avoid ruin animate this.close(); }, onCalendarOk: function onCalendarOk() { this.close(this.focusInput); }, onCalendarClear: function onCalendarClear() { this.setState({ value: null }); this.close(this.focusInput); if (this.state.value !== null) { this.props.onChange(null); } }, onCalendarChange: function onCalendarChange(value) { this.calendarInstance.setState({ value: value }); }, getInputDOMNode: function getInputDOMNode() { return _react2['default'].findDOMNode(this.inputInstance); }, getTransitionName: function getTransitionName() { var props = this.props; var transitionName = props.transitionName; if (!transitionName && props.animation) { transitionName = props.prefixCls + '-' + props.animation; } return transitionName; }, getCalendarContainer: function getCalendarContainer() { if (!this.calendarContainer) { this.calendarContainer = document.createElement('div'); this.calendarContainer.className = this.props.prefixCls + '-container'; document.body.appendChild(this.calendarContainer); } return this.calendarContainer; }, getAlign: function getAlign(orient) { var points = ['tl', 'bl']; var offset = [0, 5]; var adjustOrientOnCalendarOverflow = this.props.adjustOrientOnCalendarOverflow; if (orient.indexOf('top') !== -1 && orient.indexOf('left') !== -1) { points = ['tl', 'bl']; } else if (orient.indexOf('top') !== -1 && orient.indexOf('right') !== -1) { points = ['tr', 'br']; } else if (orient.indexOf('bottom') !== -1 && orient.indexOf('left') !== -1) { points = ['bl', 'tl']; offset = [0, -5]; } else if (orient.indexOf('bottom') !== -1 && orient.indexOf('right') !== -1) { points = ['br', 'tr']; offset = [0, -5]; } var adjustX = undefined; var adjustY = undefined; if (adjustOrientOnCalendarOverflow === true) { adjustX = adjustY = true; } else if (!adjustOrientOnCalendarOverflow) { adjustX = adjustY = false; } else { adjustX = adjustOrientOnCalendarOverflow.x; adjustY = adjustOrientOnCalendarOverflow.y; } return { points: points, offset: offset, overflow: { adjustX: adjustX, adjustY: adjustY } }; }, getCalendarElement: function getCalendarElement() { var props = this.props; var state = this.state; var calendarProp = props.calendar; var orient = undefined; // re align when open if (state.open) { orient = getImmutableOrient(calendarProp.props.orient) || orientMap.tl; } var calendarElement = _react2['default'].cloneElement(calendarProp, { ref: (0, _rcUtil.createChainedFunction)(calendarProp.ref, this.saveCalendarRef), value: state.value, visible: state.open, orient: orient, onBlur: this.onCalendarBlur, onKeyDown: this.onCalendarKeyDown, onChange: (0, _rcUtil.createChainedFunction)(calendarProp.props.onChange, this.onCalendarChange), onOk: (0, _rcUtil.createChainedFunction)(calendarProp.props.onOk, this.onCalendarOk), onSelect: (0, _rcUtil.createChainedFunction)(calendarProp.props.onSelect, this.onCalendarSelect), onClear: (0, _rcUtil.createChainedFunction)(calendarProp.props.onClear, this.onCalendarClear) }); return _react2['default'].createElement( _rcAnimate2['default'], { component: '', exclusive: true, transitionAppear: true, showProp: 'calendarOpen', transitionName: this.getTransitionName() }, _react2['default'].createElement( _rcAlign2['default'], { target: this.getInputDOMNode, key: 'calendar', onAlign: this.onCalendarAlign, calendarOpen: state.open, disabled: !state.open, align: orient && this.getAlign(orient) }, calendarElement ) ); }, render: function render() { var _classes; var props = this.props; var disabled = props.disabled; var prefixCls = props.prefixCls; var input = props.children; var state = this.state; var value = state.value; this.haveOpened = this.haveOpened || state.open; var inputValue = ''; if (value) { inputValue = props.formatter.format(value); } input = _react2['default'].cloneElement(input, { ref: (0, _rcUtil.createChainedFunction)(input.ref, this.saveInputRef), disabled: disabled, onChange: noop, onClick: disabled ? noop : this.onInputClick, value: inputValue, onKeyDown: disabled ? noop : this.onKeyDown }); var classes = (_classes = {}, _defineProperty(_classes, prefixCls, 1), _defineProperty(_classes, prefixCls + '-open', state.open), _defineProperty(_classes, prefixCls + '-disabled', disabled), _classes); var trigger = props.trigger; if (trigger) { trigger = _react2['default'].cloneElement(trigger, { unselectable: true, onMouseDown: prevent, onClick: disabled ? noop : this.onTriggerClick }); } return _react2['default'].createElement( 'span', { className: (0, _rcUtil.classSet)(classes), style: props.style }, toFragment([input, trigger]) ); }, focusInput: function focusInput() { if (!this.state.open) { this.getInputDOMNode().focus(); } }, setOpen: function setOpen(open, callback) { if (this.state.open !== open) { this.setState({ open: open }, callback); var _event = { open: open }; if (open) { this.props.onOpen(_event); } else { this.props.onClose(_event); } } }, toggle: function toggle() { if (this.state.open) { this.close(); } else { this.open(); } }, open: function open(callback) { this.setOpen(true, callback); }, close: function close(callback) { this.setOpen(false, callback); } }); exports['default'] = Picker; module.exports = exports['default']; /***/ }, /* 114 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // export this package's api Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Align = __webpack_require__(115); var _Align2 = _interopRequireDefault(_Align); exports['default'] = _Align2['default']; module.exports = exports['default']; /***/ }, /* 115 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _domAlign = __webpack_require__(116); var _domAlign2 = _interopRequireDefault(_domAlign); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); function isWindow(obj) { /*eslint-disable eqeqeq */ return obj != null && obj == obj.window; /*eslint-enable eqeqeq */ } function buffer(fn, ms) { var timer; return function () { if (timer) { clearTimeout(timer); } timer = setTimeout(fn, ms); }; } var Align = (function (_React$Component) { _inherits(Align, _React$Component); function Align(props) { _classCallCheck(this, Align); _get(Object.getPrototypeOf(Align.prototype), 'constructor', this).apply(this, arguments); this.handleWindowResize = this.handleWindowResize.bind(this); } _createClass(Align, [{ key: 'componentDidMount', value: function componentDidMount() { var props = this.props; // if parent ref not attached .... use document.getElementById if (!props.disabled) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); if (props.monitorWindowResize) { this.startMonitorWindowResize(); } } } }, { key: 'startMonitorWindowResize', value: function startMonitorWindowResize() { if (!this.resizeHandler) { this.resizeHandler = _rcUtil2['default'].Dom.addEventListener(window, 'resize', buffer(this.handleWindowResize, this.props.monitorBufferTime)); } } }, { key: 'stopMonitorWindowResize', value: function stopMonitorWindowResize() { if (this.resizeHandler) { this.resizeHandler.remove(); this.resizeHandler = null; } } }, { key: 'handleWindowResize', value: function handleWindowResize() { var props = this.props; if (!props.disabled) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.stopMonitorWindowResize(); } }, { key: 'componentDidUpdate', value: function componentDidUpdate(prevProps) { var reAlign = false; var props = this.props; var currentTarget; if (!props.disabled) { if (prevProps.disabled || prevProps.align !== props.align) { reAlign = true; currentTarget = props.target(); } else { var lastTarget = prevProps.target(); currentTarget = props.target(); if (isWindow(lastTarget) && isWindow(currentTarget)) { reAlign = false; } else if (lastTarget !== currentTarget) { reAlign = true; } } } if (reAlign) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, currentTarget, props.align)); } if (props.monitorWindowResize && !props.disabled) { this.startMonitorWindowResize(); } else { this.stopMonitorWindowResize(); } } }, { key: 'render', value: function render() { return _react2['default'].Children.only(this.props.children); } }]); return Align; })(_react2['default'].Component); Align.defaultProps = { target: function target() { return window; }, onAlign: function onAlign() {}, monitorBufferTime: 50, monitorWindowResize: false, disabled: false }; Align.PropTypes = { align: _react2['default'].PropTypes.object.isRequired, target: _react2['default'].PropTypes.func, onAlign: _react2['default'].PropTypes.func, monitorBufferTime: _react2['default'].PropTypes.number, monitorWindowResize: _react2['default'].PropTypes.bool, disabled: _react2['default'].PropTypes.bool }; exports['default'] = Align; module.exports = exports['default']; /***/ }, /* 116 */ /***/ function(module, exports, __webpack_require__) { /** * align dom node flexibly * @author yiminghe@gmail.com */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(117); var _utils2 = _interopRequireDefault(_utils); var _getOffsetParent = __webpack_require__(118); var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); var _getVisibleRectForElement = __webpack_require__(119); var _getVisibleRectForElement2 = _interopRequireDefault(_getVisibleRectForElement); var _adjustForViewport = __webpack_require__(120); var _adjustForViewport2 = _interopRequireDefault(_adjustForViewport); var _getRegion = __webpack_require__(121); var _getRegion2 = _interopRequireDefault(_getRegion); var _getElFuturePos = __webpack_require__(122); var _getElFuturePos2 = _interopRequireDefault(_getElFuturePos); // http://yiminghe.iteye.com/blog/1124720 function isFailX(elFuturePos, elRegion, visibleRect) { return elFuturePos.left < visibleRect.left || elFuturePos.left + elRegion.width > visibleRect.right; } function isFailY(elFuturePos, elRegion, visibleRect) { return elFuturePos.top < visibleRect.top || elFuturePos.top + elRegion.height > visibleRect.bottom; } function flip(points, reg, map) { var ret = []; _utils2['default'].each(points, function (p) { ret.push(p.replace(reg, function (m) { return map[m]; })); }); return ret; } function flipOffset(offset, index) { offset[index] = -offset[index]; return offset; } function convertOffset(str, offsetLen) { var n = undefined; if (/%$/.test(str)) { n = parseInt(str.substring(0, str.length - 1), 10) / 100 * offsetLen; } else { n = parseInt(str, 10); } return n || 0; } function normalizeOffset(offset, el) { offset[0] = convertOffset(offset[0], el.width); offset[1] = convertOffset(offset[1], el.height); } /* * align node * @param {Element} node current dom node * @param {Object} align align config * * @example * { * node: null, // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素 * points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tr 与参考节点的 tl 对齐 * offset: [0, 0] // 有效值为 [n, m] * } */ function domAlign(el, refNode, align) { var points = align.points; var offset = align.offset || [0, 0]; var targetOffset = align.targetOffset || [0, 0]; var overflow = align.overflow; offset = [].concat(offset); targetOffset = [].concat(targetOffset); overflow = overflow || {}; var newOverflowCfg = {}; var fail = 0; // 当前节点可以被放置的显示区域 var visibleRect = (0, _getVisibleRectForElement2['default'])(el); // 当前节点所占的区域, left/top/width/height var elRegion = (0, _getRegion2['default'])(el); // 参照节点所占的区域, left/top/width/height var refNodeRegion = (0, _getRegion2['default'])(refNode); // 将 offset 转换成数值,支持百分比 normalizeOffset(offset, elRegion); normalizeOffset(targetOffset, refNodeRegion); // 当前节点将要被放置的位置 var elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); // 当前节点将要所处的区域 var newElRegion = _utils2['default'].merge(elRegion, elFuturePos); // 如果可视区域不能完全放置当前节点时允许调整 if (visibleRect && (overflow.adjustX || overflow.adjustY)) { if (overflow.adjustX) { // 如果横向不能放下 if (isFailX(elFuturePos, elRegion, visibleRect)) { fail = 1; // 对齐位置反下 points = flip(points, /[lr]/ig, { l: 'r', r: 'l' }); // 偏移量也反下 offset = flipOffset(offset, 0); targetOffset = flipOffset(targetOffset, 0); } } if (overflow.adjustY) { // 如果纵向不能放下 if (isFailY(elFuturePos, elRegion, visibleRect)) { fail = 1; // 对齐位置反下 points = flip(points, /[tb]/ig, { t: 'b', b: 't' }); // 偏移量也反下 offset = flipOffset(offset, 1); targetOffset = flipOffset(targetOffset, 1); } } // 如果失败,重新计算当前节点将要被放置的位置 if (fail) { elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); _utils2['default'].mix(newElRegion, elFuturePos); } // 检查反下后的位置是否可以放下了 // 如果仍然放不下只有指定了可以调整当前方向才调整 newOverflowCfg.adjustX = overflow.adjustX && isFailX(elFuturePos, elRegion, visibleRect); newOverflowCfg.adjustY = overflow.adjustY && isFailY(elFuturePos, elRegion, visibleRect); // 确实要调整,甚至可能会调整高度宽度 if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) { newElRegion = (0, _adjustForViewport2['default'])(elFuturePos, elRegion, visibleRect, newOverflowCfg); } } // https://github.com/kissyteam/kissy/issues/190 // http://localhost:8888/kissy/src/overlay/demo/other/relative_align/align.html // 相对于屏幕位置没变,而 left/top 变了 // 例如 <div 'relative'><el absolute></div> _utils2['default'].offset(el, { left: newElRegion.left, top: newElRegion.top }); // need judge to in case set fixed with in css on height auto element if (newElRegion.width !== elRegion.width) { _utils2['default'].css(el, 'width', el.width() + newElRegion.width - elRegion.width); } if (newElRegion.height !== elRegion.height) { _utils2['default'].css(el, 'height', el.height() + newElRegion.height - elRegion.height); } return { points: points, offset: offset, targetOffset: targetOffset, overflow: newOverflowCfg }; } domAlign.__getOffsetParent = _getOffsetParent2['default']; domAlign.__getVisibleRectForElement = _getVisibleRectForElement2['default']; exports['default'] = domAlign; /** * 2012-04-26 yiminghe@gmail.com * - 优化智能对齐算法 * - 慎用 resizeXX * * 2011-07-13 yiminghe@gmail.com note: * - 增加智能对齐,以及大小调整选项 **/ module.exports = exports['default']; /***/ }, /* 117 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; var getComputedStyleX = undefined; function css(el, name, v) { var value = v; if (typeof name === 'object') { for (var i in name) { if (name.hasOwnProperty(i)) { css(el, i, name[i]); } } return undefined; } if (typeof value !== 'undefined') { if (typeof value === 'number') { value = value + 'px'; } el.style[name] = value; return undefined; } return getComputedStyleX(el, name); } function getClientPosition(elem) { var box = undefined; var x = undefined; var y = undefined; var doc = elem.ownerDocument; var body = doc.body; var docElem = doc && doc.documentElement; // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 box = elem.getBoundingClientRect(); // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin x = box.left; y = box.top; // In IE, most of the time, 2 extra pixels are added to the top and left // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and // IE6 standards mode, this border can be overridden by setting the // document element's border to zero -- thus, we cannot rely on the // offset always being 2 pixels. // In quirks mode, the offset can be determined by querying the body's // clientLeft/clientTop, but in standards mode, it is found by querying // the document element's clientLeft/clientTop. Since we already called // getClientBoundingRect we have already forced a reflow, so it is not // too expensive just to query them all. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 // 窗口边框标准是设 documentElement ,quirks 时设置 body // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 // 标准 ie 下 docElem.clientTop 就是 border-top // ie7 html 即窗口边框改变不了。永远为 2 // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 x -= docElem.clientLeft || body.clientLeft || 0; y -= docElem.clientTop || body.clientTop || 0; return { left: x, top: y }; } function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; // ie6,7,8 standard mode ret = d.documentElement[method]; if (typeof ret !== 'number') { // quirks mode ret = d.body[method]; } } return ret; } function getScrollLeft(w) { return getScroll(w); } function getScrollTop(w) { return getScroll(w, true); } function getOffset(el) { var pos = getClientPosition(el); var doc = el.ownerDocument; var w = doc.defaultView || doc.parentWindow; pos.left += getScrollLeft(w); pos.top += getScrollTop(w); return pos; } function _getComputedStyle(elem, name, cs) { var computedStyle = cs; var val = ''; var d = elem.ownerDocument; // https://github.com/kissyteam/kissy/issues/61 if (computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null)) { val = computedStyle.getPropertyValue(name) || computedStyle[name]; } return val; } var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); var RE_POS = /^(top|right|bottom|left)$/; var CURRENT_STYLE = 'currentStyle'; var RUNTIME_STYLE = 'runtimeStyle'; var LEFT = 'left'; var PX = 'px'; function _getComputedStyleIE(elem, name) { // currentStyle maybe null // http://msdn.microsoft.com/en-us/library/ms535231.aspx var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 // 在 ie 下不对,需要直接用 offset 方式 // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // If we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels // exclude left right for relativity if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { // Remember the original values var style = elem.style; var left = style[LEFT]; var rsLeft = elem[RUNTIME_STYLE][LEFT]; // prevent flashing of content elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; // Put in the new values to get a computed value out style[LEFT] = name === 'fontSize' ? '1em' : ret || 0; ret = style.pixelLeft + PX; // Revert the changed values style[LEFT] = left; elem[RUNTIME_STYLE][LEFT] = rsLeft; } return ret === '' ? 'auto' : ret; } if (typeof window !== 'undefined') { getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; } // 设置 elem 相对 elem.ownerDocument 的坐标 function setOffset(elem, offset) { // set position first, in-case top/left are set even on static elem if (css(elem, 'position') === 'static') { elem.style.position = 'relative'; } var preset = -9999; if ('left' in offset) { elem.style.left = preset + 'px'; } if ('top' in offset) { elem.style.top = preset + 'px'; } var old = getOffset(elem); var ret = {}; var key = undefined; for (key in offset) { if (offset.hasOwnProperty(key)) { ret[key] = preset + offset[key] - old[key]; } } css(elem, ret); } function each(arr, fn) { for (var i = 0; i < arr.length; i++) { fn(arr[i]); } } function isBorderBoxFn(elem) { return getComputedStyleX(elem, 'boxSizing') === 'border-box'; } var BOX_MODELS = ['margin', 'border', 'padding']; var CONTENT_INDEX = -1; var PADDING_INDEX = 2; var BORDER_INDEX = 1; var MARGIN_INDEX = 0; function swap(elem, options, callback) { var old = {}; var style = elem.style; var name = undefined; // Remember the old values, and insert the new ones for (name in options) { if (options.hasOwnProperty(name)) { old[name] = style[name]; style[name] = options[name]; } } callback.call(elem); // Revert the old values for (name in options) { if (options.hasOwnProperty(name)) { style[name] = old[name]; } } } function getPBMWidth(elem, props, which) { var value = 0; var prop = undefined; var j = undefined; var i = undefined; for (j = 0; j < props.length; j++) { prop = props[j]; if (prop) { for (i = 0; i < which.length; i++) { var cssProp = undefined; if (prop === 'border') { cssProp = prop + which[i] + 'Width'; } else { cssProp = prop + which[i]; } value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; } } } return value; } /** * A crude way of determining if an object is a window * @member util */ function isWindow(obj) { // must use == for ie8 /* eslint eqeqeq:0 */ return obj !== null && obj !== undefined && obj == obj.window; } var domUtils = {}; each(['Width', 'Height'], function (name) { domUtils['doc' + name] = function (refWin) { var d = refWin.document; return Math.max( // firefox chrome documentElement.scrollHeight< body.scrollHeight // ie standard mode : documentElement.scrollHeight> body.scrollHeight d.documentElement['scroll' + name], // quirks : documentElement.scrollHeight 最大等于可视窗口多一点? d.body['scroll' + name], domUtils['viewport' + name](d)); }; domUtils['viewport' + name] = function (win) { // pc browser includes scrollbar in window.innerWidth var prop = 'client' + name; var doc = win.document; var body = doc.body; var documentElement = doc.documentElement; var documentElementProp = documentElement[prop]; // 标准模式取 documentElement // backcompat 取 body return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp; }; }); /* 得到元素的大小信息 @param elem @param name @param {String} [extra] 'padding' : (css width) + padding 'border' : (css width) + padding + border 'margin' : (css width) + padding + border + margin */ function getWH(elem, name, ex) { var extra = ex; if (isWindow(elem)) { return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); } else if (elem.nodeType === 9) { return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); } var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem, computedStyle); var cssBoxValue = 0; if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) { borderBoxValue = undefined; // Fall back to computed then un computed css if necessary cssBoxValue = getComputedStyleX(elem, name); if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) { cssBoxValue = elem.style[name] || 0; } // Normalize '', auto, and prepare for extra cssBoxValue = parseFloat(cssBoxValue) || 0; } if (extra === undefined) { extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; } var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; var val = borderBoxValue || cssBoxValue; if (extra === CONTENT_INDEX) { if (borderBoxValueOrIsBorderBox) { return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle); } return cssBoxValue; } else if (borderBoxValueOrIsBorderBox) { if (extra === BORDER_INDEX) { return val; } return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle)); } return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle); } var cssShow = { position: 'absolute', visibility: 'hidden', display: 'block' }; // fix #119 : https://github.com/kissyteam/kissy/issues/119 function getWHIgnoreDisplay() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var val = undefined; var elem = args[0]; // in case elem is window // elem.offsetWidth === undefined if (elem.offsetWidth !== 0) { val = getWH.apply(undefined, args); } else { swap(elem, cssShow, function () { val = getWH.apply(undefined, args); }); } return val; } each(['width', 'height'], function (name) { var first = name.charAt(0).toUpperCase() + name.slice(1); domUtils['outer' + first] = function (el, includeMargin) { return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); }; var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; domUtils[name] = function (elem, v) { var val = v; if (val !== undefined) { if (elem) { var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem); if (isBorderBox) { val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); } return css(elem, name, val); } return undefined; } return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); }; }); function mix(to, from) { for (var i in from) { if (from.hasOwnProperty(i)) { to[i] = from[i]; } } return to; } var utils = { getWindow: function getWindow(node) { if (node && node.document && node.setTimeout) { return node; } var doc = node.ownerDocument || node; return doc.defaultView || doc.parentWindow; }, offset: function offset(el, value) { if (typeof value !== 'undefined') { setOffset(el, value); } else { return getOffset(el); } }, isWindow: isWindow, each: each, css: css, clone: function clone(obj) { var i = undefined; var ret = {}; for (i in obj) { if (obj.hasOwnProperty(i)) { ret[i] = obj[i]; } } var overflow = obj.overflow; if (overflow) { for (i in obj) { if (obj.hasOwnProperty(i)) { ret.overflow[i] = obj.overflow[i]; } } } return ret; }, mix: mix, getWindowScrollLeft: function getWindowScrollLeft(w) { return getScrollLeft(w); }, getWindowScrollTop: function getWindowScrollTop(w) { return getScrollTop(w); }, merge: function merge() { var ret = {}; for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } for (var i = 0; i < args.length; i++) { utils.mix(ret, args[i]); } return ret; }, viewportWidth: 0, viewportHeight: 0 }; mix(utils, domUtils); exports['default'] = utils; module.exports = exports['default']; /***/ }, /* 118 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(117); var _utils2 = _interopRequireDefault(_utils); /** * 得到会导致元素显示不全的祖先元素 */ function getOffsetParent(element) { // ie 这个也不是完全可行 /* <div style="width: 50px;height: 100px;overflow: hidden"> <div style="width: 50px;height: 100px;position: relative;" id="d6"> 元素 6 高 100px 宽 50px<br/> </div> </div> */ // element.offsetParent does the right thing in ie7 and below. Return parent with layout! // In other browsers it only includes elements with position absolute, relative or // fixed, not elements with overflow set to auto or scroll. // if (UA.ie && ieMode < 8) { // return element.offsetParent; // } // 统一的 offsetParent 方法 var doc = element.ownerDocument; var body = doc.body; var parent = undefined; var positionStyle = _utils2['default'].css(element, 'position'); var skipStatic = positionStyle === 'fixed' || positionStyle === 'absolute'; if (!skipStatic) { return element.nodeName.toLowerCase() === 'html' ? null : element.parentNode; } for (parent = element.parentNode; parent && parent !== body; parent = parent.parentNode) { positionStyle = _utils2['default'].css(parent, 'position'); if (positionStyle !== 'static') { return parent; } } return null; } exports['default'] = getOffsetParent; module.exports = exports['default']; /***/ }, /* 119 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(117); var _utils2 = _interopRequireDefault(_utils); var _getOffsetParent = __webpack_require__(118); var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); /** * 获得元素的显示部分的区域 */ function getVisibleRectForElement(element) { var visibleRect = { left: 0, right: Infinity, top: 0, bottom: Infinity }; var el = (0, _getOffsetParent2['default'])(element); var scrollX = undefined; var scrollY = undefined; var winSize = undefined; var doc = element.ownerDocument; var win = doc.defaultView || doc.parentWindow; var body = doc.body; var documentElement = doc.documentElement; // Determine the size of the visible rect by climbing the dom accounting for // all scrollable containers. while (el) { // clientWidth is zero for inline block elements in ie. if ((navigator.userAgent.indexOf('MSIE') === -1 || el.clientWidth !== 0) && ( // body may have overflow set on it, yet we still get the entire // viewport. In some browsers, el.offsetParent may be // document.documentElement, so check for that too. el !== body && el !== documentElement && _utils2['default'].css(el, 'overflow') !== 'visible')) { var pos = _utils2['default'].offset(el); // add border pos.left += el.clientLeft; pos.top += el.clientTop; visibleRect.top = Math.max(visibleRect.top, pos.top); visibleRect.right = Math.min(visibleRect.right, // consider area without scrollBar pos.left + el.clientWidth); visibleRect.bottom = Math.min(visibleRect.bottom, pos.top + el.clientHeight); visibleRect.left = Math.max(visibleRect.left, pos.left); } else if (el === body || el === documentElement) { break; } el = (0, _getOffsetParent2['default'])(el); } // Clip by window's viewport. scrollX = _utils2['default'].getWindowScrollLeft(win); scrollY = _utils2['default'].getWindowScrollTop(win); visibleRect.left = Math.max(visibleRect.left, scrollX); visibleRect.top = Math.max(visibleRect.top, scrollY); winSize = { width: _utils2['default'].viewportWidth(win), height: _utils2['default'].viewportHeight(win) }; visibleRect.right = Math.min(visibleRect.right, scrollX + winSize.width); visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + winSize.height); return visibleRect.top >= 0 && visibleRect.left >= 0 && visibleRect.bottom > visibleRect.top && visibleRect.right > visibleRect.left ? visibleRect : null; } exports['default'] = getVisibleRectForElement; module.exports = exports['default']; /***/ }, /* 120 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(117); var _utils2 = _interopRequireDefault(_utils); function adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) { var pos = _utils2['default'].clone(elFuturePos); var size = { width: elRegion.width, height: elRegion.height }; if (overflow.adjustX && pos.left < visibleRect.left) { pos.left = visibleRect.left; } // Left edge inside and right edge outside viewport, try to resize it. if (overflow.resizeWidth && pos.left >= visibleRect.left && pos.left + size.width > visibleRect.right) { size.width -= pos.left + size.width - visibleRect.right; } // Right edge outside viewport, try to move it. if (overflow.adjustX && pos.left + size.width > visibleRect.right) { // 保证左边界和可视区域左边界对齐 pos.left = Math.max(visibleRect.right - size.width, visibleRect.left); } // Top edge outside viewport, try to move it. if (overflow.adjustY && pos.top < visibleRect.top) { pos.top = visibleRect.top; } // Top edge inside and bottom edge outside viewport, try to resize it. if (overflow.resizeHeight && pos.top >= visibleRect.top && pos.top + size.height > visibleRect.bottom) { size.height -= pos.top + size.height - visibleRect.bottom; } // Bottom edge outside viewport, try to move it. if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) { // 保证上边界和可视区域上边界对齐 pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top); } return _utils2['default'].mix(pos, size); } exports['default'] = adjustForViewport; module.exports = exports['default']; /***/ }, /* 121 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(117); var _utils2 = _interopRequireDefault(_utils); function getRegion(node) { var offset = undefined; var w = undefined; var h = undefined; if (!_utils2['default'].isWindow(node) && node.nodeType !== 9) { offset = _utils2['default'].offset(node); w = _utils2['default'].outerWidth(node); h = _utils2['default'].outerHeight(node); } else { var win = _utils2['default'].getWindow(node); offset = { left: _utils2['default'].getWindowScrollLeft(win), top: _utils2['default'].getWindowScrollTop(win) }; w = _utils2['default'].viewportWidth(win); h = _utils2['default'].viewportHeight(win); } offset.width = w; offset.height = h; return offset; } exports['default'] = getRegion; module.exports = exports['default']; /***/ }, /* 122 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _getAlignOffset = __webpack_require__(123); var _getAlignOffset2 = _interopRequireDefault(_getAlignOffset); function getElFuturePos(elRegion, refNodeRegion, points, offset, targetOffset) { var xy = undefined; var diff = undefined; var p1 = undefined; var p2 = undefined; xy = { left: elRegion.left, top: elRegion.top }; p1 = (0, _getAlignOffset2['default'])(refNodeRegion, points[1]); p2 = (0, _getAlignOffset2['default'])(elRegion, points[0]); diff = [p2.left - p1.left, p2.top - p1.top]; return { left: xy.left - diff[0] + offset[0] - targetOffset[0], top: xy.top - diff[1] + offset[1] - targetOffset[1] }; } exports['default'] = getElFuturePos; module.exports = exports['default']; /***/ }, /* 123 */ /***/ function(module, exports) { /** * 获取 node 上的 align 对齐点 相对于页面的坐标 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function getAlignOffset(region, align) { var V = align.charAt(0); var H = align.charAt(1); var w = region.width; var h = region.height; var x = undefined; var y = undefined; x = region.left; y = region.top; if (V === 'c') { y += h / 2; } else if (V === 'b') { y += h; } if (H === 'c') { x += w / 2; } else if (H === 'r') { x += w; } return { left: x, top: y }; } exports['default'] = getAlignOffset; module.exports = exports['default']; /***/ }, /* 124 */ /***/ function(module, exports, __webpack_require__) { // export this package's api 'use strict'; module.exports = __webpack_require__(125); /***/ }, /* 125 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _ChildrenUtils = __webpack_require__(126); var _ChildrenUtils2 = _interopRequireDefault(_ChildrenUtils); var _AnimateChild = __webpack_require__(127); var _AnimateChild2 = _interopRequireDefault(_AnimateChild); var _util = __webpack_require__(131); var _util2 = _interopRequireDefault(_util); var defaultKey = 'rc_animate_' + Date.now(); function getChildrenFromProps(props) { var children = props.children; if (_react2['default'].isValidElement(children)) { if (!children.key) { return _react2['default'].cloneElement(children, { key: defaultKey }); } } return children; } function noop() {} var Animate = _react2['default'].createClass({ displayName: 'Animate', propTypes: { component: _react2['default'].PropTypes.any, animation: _react2['default'].PropTypes.object, transitionName: _react2['default'].PropTypes.string, transitionEnter: _react2['default'].PropTypes.bool, transitionAppear: _react2['default'].PropTypes.bool, transitionLeave: _react2['default'].PropTypes.bool, onEnd: _react2['default'].PropTypes.func, onEnter: _react2['default'].PropTypes.func, onLeave: _react2['default'].PropTypes.func, onAppear: _react2['default'].PropTypes.func, showProp: _react2['default'].PropTypes.string }, getDefaultProps: function getDefaultProps() { return { animation: {}, component: 'span', transitionEnter: true, transitionLeave: true, transitionAppear: false, onEnd: noop, onEnter: noop, onLeave: noop, onAppear: noop }; }, getInitialState: function getInitialState() { this.currentlyAnimatingKeys = {}; this.keysToEnter = []; this.keysToLeave = []; return { children: (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(this.props)) }; }, componentDidMount: function componentDidMount() { var _this = this; var showProp = this.props.showProp; var children = this.state.children; if (showProp) { children = children.filter(function (c) { return !!c.props[showProp]; }); } children.forEach(function (c) { _this.performAppear(c.key); }); }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var _this2 = this; var nextChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(nextProps)); var props = this.props; var showProp = props.showProp; var exclusive = props.exclusive; var currentlyAnimatingKeys = this.currentlyAnimatingKeys; // last props children if exclusive // exclusive needs immediate response var currentChildren = this.state.children; // in case destroy in showProp mode var newChildren = []; if (showProp) { currentChildren.forEach(function (currentChild) { var nextChild = (0, _ChildrenUtils.findChildInChildrenByKey)(nextChildren, currentChild.key); var newChild = undefined; if ((!nextChild || !nextChild.props[showProp]) && currentChild.props[showProp]) { newChild = _react2['default'].cloneElement(nextChild || currentChild, _defineProperty({}, showProp, true)); } else { newChild = nextChild; } if (newChild) { newChildren.push(newChild); } }); } else { newChildren = _ChildrenUtils2['default'].mergeChildren(currentChildren, nextChildren); } // exclusive needs immediate response if (exclusive) { Object.keys(currentlyAnimatingKeys).forEach(function (key) { _this2.stop(key); }); currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); } // need render to avoid update this.setState({ children: newChildren }); nextChildren.forEach(function (c) { var key = c.key; if (currentlyAnimatingKeys[key]) { return; } var hasPrev = (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key); if (showProp) { var showInNext = c.props[showProp]; if (hasPrev) { var showInNow = (0, _ChildrenUtils.findShownChildInChildrenByKey)(currentChildren, key, showProp); if (!showInNow && showInNext) { _this2.keysToEnter.push(key); } } else if (showInNext) { _this2.keysToEnter.push(key); } } else if (!hasPrev) { _this2.keysToEnter.push(key); } }); currentChildren.forEach(function (c) { var key = c.key; if (currentlyAnimatingKeys[key]) { return; } var hasNext = (0, _ChildrenUtils.findChildInChildrenByKey)(nextChildren, key); if (showProp) { var showInNow = c.props[showProp]; if (hasNext) { var showInNext = (0, _ChildrenUtils.findShownChildInChildrenByKey)(nextChildren, key, showProp); if (!showInNext && showInNow) { _this2.keysToLeave.push(key); } } else if (showInNow) { _this2.keysToLeave.push(key); } } else if (!hasNext) { _this2.keysToLeave.push(key); } }); }, componentDidUpdate: function componentDidUpdate() { var keysToEnter = this.keysToEnter; this.keysToEnter = []; keysToEnter.forEach(this.performEnter); var keysToLeave = this.keysToLeave; this.keysToLeave = []; keysToLeave.forEach(this.performLeave); }, render: function render() { var props = this.props; var stateChildren = this.state.children; var children = null; if (stateChildren) { children = stateChildren.map(function (child) { if (!child.key) { throw new Error('must set key for <rc-animate> children'); } return _react2['default'].createElement( _AnimateChild2['default'], { key: child.key, ref: child.key, animation: props.animation, transitionName: props.transitionName, transitionEnter: props.transitionEnter, transitionAppear: props.transitionAppear, transitionLeave: props.transitionLeave }, child ); }); } var Component = props.component; if (Component) { return _react2['default'].createElement( Component, this.props, children ); } return children[0] || null; }, performEnter: function performEnter(key) { // may already remove by exclusive if (this.refs[key]) { this.currentlyAnimatingKeys[key] = true; this.refs[key].componentWillEnter(this.handleDoneAdding.bind(this, key, 'enter')); } }, performAppear: function performAppear(key) { if (this.refs[key]) { this.currentlyAnimatingKeys[key] = true; this.refs[key].componentWillAppear(this.handleDoneAdding.bind(this, key, 'appear')); } }, handleDoneAdding: function handleDoneAdding(key, type) { var props = this.props; delete this.currentlyAnimatingKeys[key]; var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); if (!this.isValidChildByKey(currentChildren, key)) { // exclusive will not need this this.performLeave(key); } else { if (type === 'appear') { if (_util2['default'].allowAppearCallback(props)) { props.onAppear(key); props.onEnd(key, true); } } else { if (_util2['default'].allowEnterCallback(props)) { props.onEnter(key); props.onEnd(key, true); } } } }, performLeave: function performLeave(key) { // may already remove by exclusive if (this.refs[key]) { this.currentlyAnimatingKeys[key] = true; this.refs[key].componentWillLeave(this.handleDoneLeaving.bind(this, key)); } }, handleDoneLeaving: function handleDoneLeaving(key) { var props = this.props; delete this.currentlyAnimatingKeys[key]; var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); // in case state change is too fast if (this.isValidChildByKey(currentChildren, key)) { this.performEnter(key); } else { if (_util2['default'].allowLeaveCallback(props)) { props.onLeave(key); props.onEnd(key, false); } if (this.isMounted() && !(0, _ChildrenUtils.isSameChildren)(this.state.children, currentChildren, props.showProp)) { this.setState({ children: currentChildren }); } } }, isValidChildByKey: function isValidChildByKey(currentChildren, key) { var showProp = this.props.showProp; if (showProp) { return (0, _ChildrenUtils.findShownChildInChildrenByKey)(currentChildren, key, showProp); } return (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key); }, stop: function stop(key) { delete this.currentlyAnimatingKeys[key]; var component = this.refs[key]; if (component) { component.stop(); } } }); exports['default'] = Animate; module.exports = exports['default']; /***/ }, /* 126 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var utils = { toArrayChildren: function toArrayChildren(children) { var ret = []; _react2['default'].Children.forEach(children, function (c) { ret.push(c); }); return ret; }, findChildInChildrenByKey: function findChildInChildrenByKey(children, key) { var ret = null; if (children) { children.forEach(function (c) { if (ret) { return; } if (c.key === key) { ret = c; } }); } return ret; }, findShownChildInChildrenByKey: function findShownChildInChildrenByKey(children, key, showProp) { var ret = null; if (children) { children.forEach(function (c) { if (c.key === key && c.props[showProp]) { if (ret) { throw new Error('two child with same key for <rc-animate> children'); } ret = c; } }); } return ret; }, findHiddenChildInChildrenByKey: function findHiddenChildInChildrenByKey(children, key, showProp) { var found = 0; if (children) { children.forEach(function (c) { if (found) { return; } found = c.key === key && !c.props[showProp]; }); } return found; }, isSameChildren: function isSameChildren(c1, c2, showProp) { var same = c1.length === c2.length; if (same) { c1.forEach(function (child, i) { var child2 = c2[i]; if (child.key !== child2.key) { same = false; } else if (showProp && child.props[showProp] !== child2.props[showProp]) { same = false; } }); } return same; }, mergeChildren: function mergeChildren(prev, next) { var ret = []; // For each key of `next`, the list of keys to insert before that key in // the combined list var nextChildrenPending = {}; var pendingChildren = []; prev.forEach(function (c) { if (utils.findChildInChildrenByKey(next, c.key)) { if (pendingChildren.length) { nextChildrenPending[c.key] = pendingChildren; pendingChildren = []; } } else { pendingChildren.push(c); } }); next.forEach(function (c) { if (nextChildrenPending.hasOwnProperty(c.key)) { ret = ret.concat(nextChildrenPending[c.key]); } ret.push(c); }); ret = ret.concat(pendingChildren); return ret; } }; exports['default'] = utils; module.exports = exports['default']; /***/ }, /* 127 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _cssAnimation = __webpack_require__(128); var _cssAnimation2 = _interopRequireDefault(_cssAnimation); var _util = __webpack_require__(131); var _util2 = _interopRequireDefault(_util); var transitionMap = { enter: 'transitionEnter', appear: 'transitionAppear', leave: 'transitionLeave' }; var AnimateChild = _react2['default'].createClass({ displayName: 'AnimateChild', propTypes: { children: _react2['default'].PropTypes.any }, transition: function transition(animationType, finishCallback) { var _this = this; var node = _react2['default'].findDOMNode(this); var props = this.props; var transitionName = props.transitionName; this.stop(); var end = function end() { _this.stopper = null; finishCallback(); }; if ((_cssAnimation.isCssAnimationSupported || !props.animation[animationType]) && transitionName && props[transitionMap[animationType]]) { this.stopper = (0, _cssAnimation2['default'])(node, transitionName + '-' + animationType, end); } else { this.stopper = props.animation[animationType](node, end); } }, stop: function stop() { if (this.stopper) { this.stopper.stop(); this.stopper = null; } }, componentWillUnmount: function componentWillUnmount() { this.stop(); }, componentWillEnter: function componentWillEnter(done) { if (_util2['default'].isEnterSupported(this.props)) { this.transition('enter', done); } else { done(); } }, componentWillAppear: function componentWillAppear(done) { if (_util2['default'].isAppearSupported(this.props)) { this.transition('appear', done); } else { done(); } }, componentWillLeave: function componentWillLeave(done) { if (_util2['default'].isLeaveSupported(this.props)) { this.transition('leave', done); } else { done(); } }, render: function render() { return this.props.children; } }); exports['default'] = AnimateChild; module.exports = exports['default']; /***/ }, /* 128 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var Event = __webpack_require__(129); var Css = __webpack_require__(130); var isCssAnimationSupported = Event.endEvents.length !== 0; function getDuration(node, name) { var style = window.getComputedStyle(node); var prefixes = ['-webkit-', '-moz-', '-o-', 'ms-', '']; var ret = ''; for (var i = 0; i < prefixes.length; i++) { ret = style.getPropertyValue(prefixes[i] + name); if (ret) { break; } } return ret; } function fixBrowserByTimeout(node) { if (isCssAnimationSupported) { var transitionDuration = parseFloat(getDuration(node, 'transition-duration')) || 0; var animationDuration = parseFloat(getDuration(node, 'animation-duration')) || 0; var time = Math.max(transitionDuration, animationDuration); // sometimes, browser bug node.rcEndAnimTimeout = setTimeout(function () { node.rcEndAnimTimeout = null; if (node.rcEndListener) { node.rcEndListener(); } }, time * 1000 + 200); } } function clearBrowserBugTimeout(node) { if (node.rcEndAnimTimeout) { clearTimeout(node.rcEndAnimTimeout); node.rcEndAnimTimeout = null; } } var cssAnimation = function cssAnimation(node, transitionName, callback) { var className = transitionName; var activeClassName = className + '-active'; if (node.rcEndListener) { node.rcEndListener(); } node.rcEndListener = function (e) { if (e && e.target !== node) { return; } if (node.rcAnimTimeout) { clearTimeout(node.rcAnimTimeout); node.rcAnimTimeout = null; } clearBrowserBugTimeout(node); Css.removeClass(node, className); Css.removeClass(node, activeClassName); Event.removeEndEventListener(node, node.rcEndListener); node.rcEndListener = null; // Usually this optional callback is used for informing an owner of // a leave animation and telling it to remove the child. if (callback) { callback(); } }; Event.addEndEventListener(node, node.rcEndListener); Css.addClass(node, className); node.rcAnimTimeout = setTimeout(function () { node.rcAnimTimeout = null; Css.addClass(node, activeClassName); fixBrowserByTimeout(node); }, 0); return { stop: function stop() { if (node.rcEndListener) { node.rcEndListener(); } } }; }; cssAnimation.style = function (node, style, callback) { if (node.rcEndListener) { node.rcEndListener(); } node.rcEndListener = function (e) { if (e && e.target !== node) { return; } if (node.rcAnimTimeout) { clearTimeout(node.rcAnimTimeout); node.rcAnimTimeout = null; } clearBrowserBugTimeout(node); Event.removeEndEventListener(node, node.rcEndListener); node.rcEndListener = null; // Usually this optional callback is used for informing an owner of // a leave animation and telling it to remove the child. if (callback) { callback(); } }; Event.addEndEventListener(node, node.rcEndListener); node.rcAnimTimeout = setTimeout(function () { for (var s in style) { if (style.hasOwnProperty(s)) { node.style[s] = style[s]; } } node.rcAnimTimeout = null; fixBrowserByTimeout(node); }, 0); }; cssAnimation.setTransition = function (node, p, value) { var property = p; var v = value; if (value === undefined) { v = property; property = ''; } property = property || ''; ['Webkit', 'Moz', 'O', // ms is special .... ! 'ms'].forEach(function (prefix) { node.style[prefix + 'Transition' + property] = v; }); }; cssAnimation.addClass = Css.addClass; cssAnimation.removeClass = Css.removeClass; cssAnimation.isCssAnimationSupported = isCssAnimationSupported; module.exports = cssAnimation; /***/ }, /* 129 */ /***/ function(module, exports) { 'use strict'; var EVENT_NAME_MAP = { transitionend: { transition: 'transitionend', WebkitTransition: 'webkitTransitionEnd', MozTransition: 'mozTransitionEnd', OTransition: 'oTransitionEnd', msTransition: 'MSTransitionEnd' }, animationend: { animation: 'animationend', WebkitAnimation: 'webkitAnimationEnd', MozAnimation: 'mozAnimationEnd', OAnimation: 'oAnimationEnd', msAnimation: 'MSAnimationEnd' } }; var endEvents = []; function detectEvents() { var testEl = document.createElement('div'); var style = testEl.style; if (!('AnimationEvent' in window)) { delete EVENT_NAME_MAP.animationend.animation; } if (!('TransitionEvent' in window)) { delete EVENT_NAME_MAP.transitionend.transition; } for (var baseEventName in EVENT_NAME_MAP) { if (EVENT_NAME_MAP.hasOwnProperty(baseEventName)) { var baseEvents = EVENT_NAME_MAP[baseEventName]; for (var styleName in baseEvents) { if (styleName in style) { endEvents.push(baseEvents[styleName]); break; } } } } } if (typeof window !== 'undefined') { detectEvents(); } function addEventListener(node, eventName, eventListener) { node.addEventListener(eventName, eventListener, false); } function removeEventListener(node, eventName, eventListener) { node.removeEventListener(eventName, eventListener, false); } var TransitionEvents = { addEndEventListener: function addEndEventListener(node, eventListener) { if (endEvents.length === 0) { window.setTimeout(eventListener, 0); return; } endEvents.forEach(function (endEvent) { addEventListener(node, endEvent, eventListener); }); }, endEvents: endEvents, removeEndEventListener: function removeEndEventListener(node, eventListener) { if (endEvents.length === 0) { return; } endEvents.forEach(function (endEvent) { removeEventListener(node, endEvent, eventListener); }); } }; module.exports = TransitionEvents; /***/ }, /* 130 */ /***/ function(module, exports) { 'use strict'; var SPACE = ' '; var RE_CLASS = /[\n\t\r]/g; function norm(elemClass) { return (SPACE + elemClass + SPACE).replace(RE_CLASS, SPACE); } module.exports = { addClass: function addClass(elem, className) { elem.className += ' ' + className; }, removeClass: function removeClass(elem, n) { var elemClass = elem.className.trim(); var className = norm(elemClass); var needle = n.trim(); needle = SPACE + needle + SPACE; // 一个 cls 有可能多次出现:'link link2 link link3 link' while (className.indexOf(needle) >= 0) { className = className.replace(needle, SPACE); } elem.className = className.trim(); } }; /***/ }, /* 131 */ /***/ function(module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var util = { isAppearSupported: function isAppearSupported(props) { return props.transitionName && props.transitionAppear || props.animation.appear; }, isEnterSupported: function isEnterSupported(props) { return props.transitionName && props.transitionEnter || props.animation.enter; }, isLeaveSupported: function isLeaveSupported(props) { return props.transitionName && props.transitionLeave || props.animation.leave; }, allowAppearCallback: function allowAppearCallback(props) { return props.transitionAppear || props.animation.appear; }, allowEnterCallback: function allowEnterCallback(props) { return props.transitionEnter || props.animation.enter; }, allowLeaveCallback: function allowLeaveCallback(props) { return props.transitionLeave || props.animation.leave; } }; exports["default"] = util; module.exports = exports["default"]; /***/ }, /* 132 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _monthMonthPanel = __webpack_require__(105); var _monthMonthPanel2 = _interopRequireDefault(_monthMonthPanel); var _mixinCalendarMixin = __webpack_require__(111); var _mixinCalendarMixin2 = _interopRequireDefault(_mixinCalendarMixin); var _rcUtil = __webpack_require__(77); var MonthCalendar = _react2['default'].createClass({ displayName: 'MonthCalendar', mixins: [_mixinCalendarMixin2['default']], onKeyDown: function onKeyDown(e) { var keyCode = e.keyCode; var ctrlKey = e.ctrlKey || e.metaKey; var stateValue = this.state.value; var value = stateValue; switch (keyCode) { case _rcUtil.KeyCode.DOWN: value = stateValue.clone(); value.addMonth(3); break; case _rcUtil.KeyCode.UP: value = stateValue.clone(); value.addMonth(-3); break; case _rcUtil.KeyCode.LEFT: value = stateValue.clone(); if (ctrlKey) { value.addYear(-1); } else { value.addMonth(-1); } break; case _rcUtil.KeyCode.RIGHT: value = stateValue.clone(); if (ctrlKey) { value.addYear(1); } else { value.addMonth(1); } break; case _rcUtil.KeyCode.ENTER: this.onSelect(stateValue); e.preventDefault(); return 1; default: return undefined; } if (value !== stateValue) { this.setValue(value); e.preventDefault(); return 1; } }, render: function render() { var props = this.props; var children = _react2['default'].createElement(_monthMonthPanel2['default'], { locale: props.locale, disabledDate: props.disabledDate, style: { position: 'relative' }, value: this.state.value, rootPrefixCls: props.prefixCls, onChange: this.setValue, onSelect: this.onSelect }); return this.renderRoot({ children: children }); } }); exports['default'] = MonthCalendar; module.exports = exports['default']; /***/ }, /* 133 */ /***/ function(module, exports) { /** * zh-cn locale * @ignore * @author yiminghe@gmail.com */ module.exports = { // in minutes timezoneOffset: 8 * 60, firstDayOfWeek: 1, minimalDaysInFirstWeek: 1 }; /***/ }, /* 134 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _gregorianCalendarFormatLibLocaleZhCn = __webpack_require__(135); var _gregorianCalendarFormatLibLocaleZhCn2 = _interopRequireDefault(_gregorianCalendarFormatLibLocaleZhCn); exports['default'] = { today: '今天', now: '此刻', ok: '确定', clear: '清除', previousMonth: '上个月 (翻页上键)', nextMonth: '下个月 (翻页下键)', monthSelect: '选择月份', yearSelect: '选择年份', decadeSelect: '选择年代', hourInput: '上一小时(上方向键), 下一小时(下方向键)', minuteInput: '上一分钟(上方向键), 下一分钟(下方向键)', secondInput: '上一秒(上方向键), 下一小时(下方向键)', hourPanelTitle: '选择小时', minutePanelTitle: '选择分钟', secondPanelTitle: '选择秒', yearFormat: 'yyyy\'年\'', monthFormat: 'M\'月\'', dateFormat: 'yyyy\'年\'M\'月\'d\'日\'', previousYear: '上一年 (Control键加左方向键)', nextYear: '下一年 (Control键加右方向键)', previousDecade: '上一年代', nextDecade: '下一年代', previousCentury: '上一世纪', nextCentury: '下一世纪', format: _gregorianCalendarFormatLibLocaleZhCn2['default'] }; module.exports = exports['default']; /***/ }, /* 135 */ /***/ function(module, exports) { /** * zh-cn locale * @ignore * @author yiminghe@gmail.com */ module.exports = { eras: ['公元前', '公元'], months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], shortMonths: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], weekdays: ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], shortWeekdays: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], veryShortWeekdays: ['日', '一', '二', '三', '四', '五', '六'], ampms: ['上午', '下午'], /*jshint quotmark: false*/ datePatterns: ["yyyy'年'M'月'd'日' EEEE", "yyyy'年'M'月'd'日'", "yyyy-M-d", "yy-M-d"], timePatterns: ["ahh'时'mm'分'ss'秒' 'GMT'Z", "ahh'时'mm'分'ss'秒'", "H:mm:ss", "ah:mm"], dateTimePattern: '{date} {time}' }; /***/ }, /* 136 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcTooltip = __webpack_require__(137); var _rcTooltip2 = _interopRequireDefault(_rcTooltip); exports['default'] = _react2['default'].createClass({ displayName: 'index', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-tooltip', placement: 'top', mouseEnterDelay: 0.1, mouseLeaveDelay: 0.1 }; }, getInitialState: function getInitialState() { return { visible: false }; }, onVisibleChange: function onVisibleChange(visible) { this.setState({ visible: visible }); }, render: function render() { var transitionName = ({ top: 'zoom-down', bottom: 'zoom-up', left: 'zoom-right', right: 'zoom-left' })[this.props.placement]; // Hide tooltip when there is no title var visible = this.state.visible; if (!this.props.title) { visible = false; } return _react2['default'].createElement( _rcTooltip2['default'], _extends({ transitionName: transitionName, overlay: this.props.title, visible: visible, onVisibleChange: this.onVisibleChange }, this.props), this.props.children ); } }); module.exports = exports['default']; /***/ }, /* 137 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(138); /***/ }, /* 138 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _Popup = __webpack_require__(139); var _Popup2 = _interopRequireDefault(_Popup); var Tooltip = _react2['default'].createClass({ displayName: 'Tooltip', propTypes: { trigger: _react2['default'].PropTypes.any, placement: _react2['default'].PropTypes.any, onVisibleChange: _react2['default'].PropTypes.func, afterVisibleChange: _react2['default'].PropTypes.func, overlay: _react2['default'].PropTypes.node.isRequired, overlayStyle: _react2['default'].PropTypes.object, overlayClassName: _react2['default'].PropTypes.string, wrapStyle: _react2['default'].PropTypes.object, mouseEnterDelay: _react2['default'].PropTypes.number, mouseLeaveDelay: _react2['default'].PropTypes.number, getTooltipContainer: _react2['default'].PropTypes.func }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-tooltip', onVisibleChange: function onVisibleChange() {}, afterVisibleChange: function afterVisibleChange() {}, mouseEnterDelay: 0, mouseLeaveDelay: 0.1, overlayStyle: {}, wrapStyle: {}, placement: 'right', trigger: ['hover'] }; }, getInitialState: function getInitialState() { var props = this.props; var visible = undefined; if ('visible' in props) { visible = props.visible; } else { visible = props.defaultVisible; } return { visible: visible }; }, componentDidMount: function componentDidMount() { this.componentDidUpdate(this.props, this.state); }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('visible' in nextProps) { this.setState({ visible: !!nextProps.visible }); } }, componentDidUpdate: function componentDidUpdate(prevProps, prevState) { var _this = this; var props = this.props; var state = this.state; if (this.popupRendered) { var _ret = (function () { var self = _this; _react2['default'].render(_this.getPopupElement(), _this.getTipContainer(), function renderPopup() { self.popupInstance = this; if (prevState.visible !== state.visible) { props.afterVisibleChange(state.visible); } }); if (props.trigger.indexOf('click') !== -1) { if (state.visible) { if (!_this.clickOutsideHandler) { _this.clickOutsideHandler = _rcUtil.Dom.addEventListener(document, 'mousedown', _this.onDocumentClick); _this.touchOutsideHandler = _rcUtil.Dom.addEventListener(document, 'touchstart', _this.onDocumentClick); } return { v: undefined }; } } if (_this.clickOutsideHandler) { _this.clickOutsideHandler.remove(); _this.touchOutsideHandler.remove(); _this.clickOutsideHandler = null; _this.touchOutsideHandler = null; } })(); if (typeof _ret === 'object') return _ret.v; } }, componentWillUnmount: function componentWillUnmount() { var tipContainer = this.tipContainer; if (tipContainer) { _react2['default'].unmountComponentAtNode(tipContainer); if (this.props.getTooltipContainer) { var mountNode = this.props.getTooltipContainer(); mountNode.removeChild(tipContainer); } else { document.body.removeChild(tipContainer); } this.tipContainer = null; } if (this.delayTimer) { clearTimeout(this.delayTimer); this.delayTimer = null; } if (this.clickOutsideHandler) { this.clickOutsideHandler.remove(); this.touchOutsideHandler.remove(); this.clickOutsideHandler = null; this.touchOutsideHandler = null; } }, onMouseEnter: function onMouseEnter() { this.delaySetVisible(true, this.props.mouseEnterDelay); }, onMouseLeave: function onMouseLeave() { this.delaySetVisible(false, this.props.mouseLeaveDelay); }, onFocus: function onFocus() { this.focusTime = Date.now(); this.setVisible(true); }, onMouseDown: function onMouseDown() { this.preClickTime = Date.now(); }, onTouchStart: function onTouchStart() { this.preTouchTime = Date.now(); }, onBlur: function onBlur() { this.setVisible(false); }, onClick: function onClick(e) { // focus will trigger click if (this.focusTime) { var preTime = undefined; if (this.preClickTime && this.preTouchTime) { preTime = Math.min(this.preClickTime, this.preTouchTime); } else if (this.preClickTime) { preTime = this.preClickTime; } else if (this.preTouchTime) { preTime = this.preTouchTime; } if (Math.abs(preTime - this.focusTime) < 20) { return; } this.focusTime = 0; } this.preClickTime = 0; this.preTouchTime = 0; e.preventDefault(); if (this.state.visible) { this.setVisible(false); } else { this.setVisible(true); } }, onDocumentClick: function onDocumentClick(e) { var target = e.target; var root = _react2['default'].findDOMNode(this); var popupNode = this.getPopupDomNode(); if (!_rcUtil.Dom.contains(root, target) && !_rcUtil.Dom.contains(popupNode, target)) { this.setVisible(false); } }, getPopupDomNode: function getPopupDomNode() { // for test return this.popupInstance.getPopupDomNode(); }, getTipContainer: function getTipContainer() { if (!this.tipContainer) { this.tipContainer = document.createElement('div'); if (this.props.getTooltipContainer) { var mountNode = this.props.getTooltipContainer(); mountNode.appendChild(this.tipContainer); } else { document.body.appendChild(this.tipContainer); } } return this.tipContainer; }, getPopupElement: function getPopupElement() { if (!this.popupRendered) { return null; } var props = this.props; var state = this.state; var mouseProps = {}; if (props.trigger.indexOf('hover') !== -1) { mouseProps.onMouseEnter = this.onMouseEnter; mouseProps.onMouseLeave = this.onMouseLeave; } return _react2['default'].createElement( _Popup2['default'], _extends({ prefixCls: props.prefixCls, visible: state.visible, className: props.overlayClassName, trigger: props.trigger, placement: props.placement, animation: props.animation }, mouseProps, { wrap: this, style: props.overlayStyle, transitionName: props.transitionName }), props.overlay ); }, render: function render() { if (this.state.visible) { this.popupRendered = true; } var props = this.props; var children = props.children; var child = _react2['default'].Children.only(children); var childProps = child.props || {}; var newChildProps = {}; var trigger = props.trigger; if (trigger.indexOf('click') !== -1) { newChildProps.onClick = (0, _rcUtil.createChainedFunction)(this.onClick, childProps.onClick); newChildProps.onMouseDown = (0, _rcUtil.createChainedFunction)(this.onMouseDown, childProps.onMouseDown); newChildProps.onTouchStart = (0, _rcUtil.createChainedFunction)(this.onTouchStart, childProps.onTouchStart); } if (trigger.indexOf('hover') !== -1) { newChildProps.onMouseEnter = (0, _rcUtil.createChainedFunction)(this.onMouseEnter, childProps.onMouseEnter); newChildProps.onMouseLeave = (0, _rcUtil.createChainedFunction)(this.onMouseLeave, childProps.onMouseLeave); } if (trigger.indexOf('focus') !== -1) { newChildProps.onFocus = (0, _rcUtil.createChainedFunction)(this.onFocus, childProps.onFocus); newChildProps.onBlur = (0, _rcUtil.createChainedFunction)(this.onBlur, childProps.onBlur); } var className = props.prefixCls + '-wrap'; if (this.state.visible) { className += ' ' + props.prefixCls + '-wrap-open'; } return _react2['default'].createElement( 'span', { className: className, style: props.wrapStyle }, _react2['default'].cloneElement(child, newChildProps) ); }, setVisible: function setVisible(visible) { if (this.state.visible !== visible) { if (!('visible' in this.props)) { this.setState({ visible: visible }); } this.props.onVisibleChange(visible); } }, delaySetVisible: function delaySetVisible(visible, delayS) { var _this2 = this; var delay = delayS * 1000; if (this.delayTimer) { clearTimeout(this.delayTimer); this.delayTimer = null; } if (delay) { this.delayTimer = setTimeout(function () { _this2.setVisible(visible); _this2.delayTimer = null; }, delay); } else { this.setVisible(visible); } } }); exports['default'] = Tooltip; module.exports = exports['default']; /***/ }, /* 139 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _utils = __webpack_require__(140); var _rcAlign = __webpack_require__(141); var _rcAlign2 = _interopRequireDefault(_rcAlign); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var placementAlignMap = { left: { points: ['cr', 'cl'] }, right: { points: ['cl', 'cr'] }, top: { points: ['bc', 'tc'] }, bottom: { points: ['tc', 'bc'] } }; var Popup = _react2['default'].createClass({ displayName: 'Popup', propTypes: { visible: _react2['default'].PropTypes.bool, wrap: _react2['default'].PropTypes.object, style: _react2['default'].PropTypes.object, onMouseEnter: _react2['default'].PropTypes.func, onMouseLeave: _react2['default'].PropTypes.func }, // optimize for speed shouldComponentUpdate: function shouldComponentUpdate(nextProps) { return this.props.visible || nextProps.visible; }, onAlign: function onAlign(popupDomNode, align) { var props = this.props; var placement = props.placement; if (placement && placement.points) { var originalClassName = (0, _utils.getToolTipClassByPlacement)(props.prefixCls, placement); var nextClassName = (0, _utils.getToolTipClassByPlacement)(props.prefixCls, align); if (nextClassName !== originalClassName) { popupDomNode.className = popupDomNode.className.replace(originalClassName, nextClassName); } } }, getPopupDomNode: function getPopupDomNode() { return _react2['default'].findDOMNode(this); }, getTarget: function getTarget() { return _react2['default'].findDOMNode(this.props.wrap).firstChild; }, getTransitionName: function getTransitionName() { var props = this.props; var transitionName = props.transitionName; if (!transitionName && props.animation) { transitionName = props.prefixCls + '-' + props.animation; } return transitionName; }, render: function render() { var props = this.props; var className = (0, _utils.getToolTipClassByPlacement)(props.prefixCls, props.placement); if (props.className) { className += ' ' + props.className; } var style = this.props.style; if (!props.visible) { className += ' ' + props.prefixCls + '-hidden'; } var arrowClassName = props.prefixCls + '-arrow'; var innerClassname = props.prefixCls + '-inner'; var placement = props.placement; var align = undefined; if (placement && placement.points) { align = placement; } else { align = placementAlignMap[placement]; } return _react2['default'].createElement( _rcAnimate2['default'], { component: '', exclusive: true, transitionAppear: true, transitionName: this.getTransitionName(), showProp: 'data-visible' }, _react2['default'].createElement( _rcAlign2['default'], { target: this.getTarget, key: 'popup', monitorWindowResize: true, 'data-visible': props.visible, disabled: !props.visible, align: align, onAlign: this.onAlign }, _react2['default'].createElement( 'div', { className: className, onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave, style: style }, _react2['default'].createElement('div', { className: arrowClassName }), _react2['default'].createElement( 'div', { className: innerClassname }, props.children ) ) ) ); } }); exports['default'] = Popup; module.exports = exports['default']; /***/ }, /* 140 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports.getToolTipClassByPlacement = getToolTipClassByPlacement; function getToolTipClassByPlacement(prefixCls, placement) { if (typeof placement === 'string') { return prefixCls + ' ' + prefixCls + '-placement-' + placement; } var offset = placement.offset || [0, 0]; var offsetClass = ''; if (offset && offset.length) { offsetClass = prefixCls + '-placement-offset-x-' + offset[0] + ' ' + prefixCls + '-placement-offset-y-' + offset[1]; } var points = placement.points; return prefixCls + ' ' + offsetClass + ' ' + prefixCls + '-placement-points-' + points[0] + '-' + points[1]; } /***/ }, /* 141 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // export this package's api Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Align = __webpack_require__(142); var _Align2 = _interopRequireDefault(_Align); exports['default'] = _Align2['default']; module.exports = exports['default']; /***/ }, /* 142 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _domAlign = __webpack_require__(143); var _domAlign2 = _interopRequireDefault(_domAlign); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); function isWindow(obj) { /*eslint-disable eqeqeq */ return obj != null && obj == obj.window; /*eslint-enable eqeqeq */ } function buffer(fn, ms) { var timer; return function () { if (timer) { clearTimeout(timer); } timer = setTimeout(fn, ms); }; } var Align = (function (_React$Component) { _inherits(Align, _React$Component); function Align(props) { _classCallCheck(this, Align); _get(Object.getPrototypeOf(Align.prototype), 'constructor', this).apply(this, arguments); this.handleWindowResize = this.handleWindowResize.bind(this); } _createClass(Align, [{ key: 'componentDidMount', value: function componentDidMount() { var props = this.props; // if parent ref not attached .... use document.getElementById if (!props.disabled) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); if (props.monitorWindowResize) { this.startMonitorWindowResize(); } } } }, { key: 'startMonitorWindowResize', value: function startMonitorWindowResize() { if (!this.resizeHandler) { this.resizeHandler = _rcUtil2['default'].Dom.addEventListener(window, 'resize', buffer(this.handleWindowResize, this.props.monitorBufferTime)); } } }, { key: 'stopMonitorWindowResize', value: function stopMonitorWindowResize() { if (this.resizeHandler) { this.resizeHandler.remove(); this.resizeHandler = null; } } }, { key: 'handleWindowResize', value: function handleWindowResize() { var props = this.props; if (!props.disabled) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.stopMonitorWindowResize(); } }, { key: 'componentDidUpdate', value: function componentDidUpdate(prevProps) { var reAlign = false; var props = this.props; var currentTarget; if (!props.disabled) { if (prevProps.disabled || prevProps.align !== props.align) { reAlign = true; currentTarget = props.target(); } else { var lastTarget = prevProps.target(); currentTarget = props.target(); if (isWindow(lastTarget) && isWindow(currentTarget)) { reAlign = false; } else if (lastTarget !== currentTarget) { reAlign = true; } } } if (reAlign) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, currentTarget, props.align)); } if (props.monitorWindowResize && !props.disabled) { this.startMonitorWindowResize(); } else { this.stopMonitorWindowResize(); } } }, { key: 'render', value: function render() { return _react2['default'].Children.only(this.props.children); } }]); return Align; })(_react2['default'].Component); Align.defaultProps = { target: function target() { return window; }, onAlign: function onAlign() {}, monitorBufferTime: 50, monitorWindowResize: false, disabled: false }; Align.PropTypes = { align: _react2['default'].PropTypes.object.isRequired, target: _react2['default'].PropTypes.func, onAlign: _react2['default'].PropTypes.func, monitorBufferTime: _react2['default'].PropTypes.number, monitorWindowResize: _react2['default'].PropTypes.bool, disabled: _react2['default'].PropTypes.bool }; exports['default'] = Align; module.exports = exports['default']; /***/ }, /* 143 */ /***/ function(module, exports, __webpack_require__) { /** * align dom node flexibly * @author yiminghe@gmail.com */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(144); var _utils2 = _interopRequireDefault(_utils); var _getOffsetParent = __webpack_require__(145); var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); var _getVisibleRectForElement = __webpack_require__(146); var _getVisibleRectForElement2 = _interopRequireDefault(_getVisibleRectForElement); var _adjustForViewport = __webpack_require__(147); var _adjustForViewport2 = _interopRequireDefault(_adjustForViewport); var _getRegion = __webpack_require__(148); var _getRegion2 = _interopRequireDefault(_getRegion); var _getElFuturePos = __webpack_require__(149); var _getElFuturePos2 = _interopRequireDefault(_getElFuturePos); // http://yiminghe.iteye.com/blog/1124720 function isFailX(elFuturePos, elRegion, visibleRect) { return elFuturePos.left < visibleRect.left || elFuturePos.left + elRegion.width > visibleRect.right; } function isFailY(elFuturePos, elRegion, visibleRect) { return elFuturePos.top < visibleRect.top || elFuturePos.top + elRegion.height > visibleRect.bottom; } function flip(points, reg, map) { var ret = []; _utils2['default'].each(points, function (p) { ret.push(p.replace(reg, function (m) { return map[m]; })); }); return ret; } function flipOffset(offset, index) { offset[index] = -offset[index]; return offset; } function convertOffset(str, offsetLen) { var n = undefined; if (/%$/.test(str)) { n = parseInt(str.substring(0, str.length - 1), 10) / 100 * offsetLen; } else { n = parseInt(str, 10); } return n || 0; } function normalizeOffset(offset, el) { offset[0] = convertOffset(offset[0], el.width); offset[1] = convertOffset(offset[1], el.height); } /* * align node * @param {Element} node current dom node * @param {Object} align align config * * @example * { * node: null, // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素 * points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tr 与参考节点的 tl 对齐 * offset: [0, 0] // 有效值为 [n, m] * } */ function domAlign(el, refNode, align) { var points = align.points; var offset = align.offset || [0, 0]; var targetOffset = align.targetOffset || [0, 0]; var overflow = align.overflow; offset = [].concat(offset); targetOffset = [].concat(targetOffset); overflow = overflow || {}; var newOverflowCfg = {}; var fail = 0; // 当前节点可以被放置的显示区域 var visibleRect = (0, _getVisibleRectForElement2['default'])(el); // 当前节点所占的区域, left/top/width/height var elRegion = (0, _getRegion2['default'])(el); // 参照节点所占的区域, left/top/width/height var refNodeRegion = (0, _getRegion2['default'])(refNode); // 将 offset 转换成数值,支持百分比 normalizeOffset(offset, elRegion); normalizeOffset(targetOffset, refNodeRegion); // 当前节点将要被放置的位置 var elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); // 当前节点将要所处的区域 var newElRegion = _utils2['default'].merge(elRegion, elFuturePos); // 如果可视区域不能完全放置当前节点时允许调整 if (visibleRect && (overflow.adjustX || overflow.adjustY)) { if (overflow.adjustX) { // 如果横向不能放下 if (isFailX(elFuturePos, elRegion, visibleRect)) { fail = 1; // 对齐位置反下 points = flip(points, /[lr]/ig, { l: 'r', r: 'l' }); // 偏移量也反下 offset = flipOffset(offset, 0); targetOffset = flipOffset(targetOffset, 0); } } if (overflow.adjustY) { // 如果纵向不能放下 if (isFailY(elFuturePos, elRegion, visibleRect)) { fail = 1; // 对齐位置反下 points = flip(points, /[tb]/ig, { t: 'b', b: 't' }); // 偏移量也反下 offset = flipOffset(offset, 1); targetOffset = flipOffset(targetOffset, 1); } } // 如果失败,重新计算当前节点将要被放置的位置 if (fail) { elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); _utils2['default'].mix(newElRegion, elFuturePos); } // 检查反下后的位置是否可以放下了 // 如果仍然放不下只有指定了可以调整当前方向才调整 newOverflowCfg.adjustX = overflow.adjustX && isFailX(elFuturePos, elRegion, visibleRect); newOverflowCfg.adjustY = overflow.adjustY && isFailY(elFuturePos, elRegion, visibleRect); // 确实要调整,甚至可能会调整高度宽度 if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) { newElRegion = (0, _adjustForViewport2['default'])(elFuturePos, elRegion, visibleRect, newOverflowCfg); } } // https://github.com/kissyteam/kissy/issues/190 // http://localhost:8888/kissy/src/overlay/demo/other/relative_align/align.html // 相对于屏幕位置没变,而 left/top 变了 // 例如 <div 'relative'><el absolute></div> _utils2['default'].offset(el, { left: newElRegion.left, top: newElRegion.top }); // need judge to in case set fixed with in css on height auto element if (newElRegion.width !== elRegion.width) { _utils2['default'].css(el, 'width', el.width() + newElRegion.width - elRegion.width); } if (newElRegion.height !== elRegion.height) { _utils2['default'].css(el, 'height', el.height() + newElRegion.height - elRegion.height); } return { points: points, offset: offset, targetOffset: targetOffset, overflow: newOverflowCfg }; } domAlign.__getOffsetParent = _getOffsetParent2['default']; domAlign.__getVisibleRectForElement = _getVisibleRectForElement2['default']; exports['default'] = domAlign; /** * 2012-04-26 yiminghe@gmail.com * - 优化智能对齐算法 * - 慎用 resizeXX * * 2011-07-13 yiminghe@gmail.com note: * - 增加智能对齐,以及大小调整选项 **/ module.exports = exports['default']; /***/ }, /* 144 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; var getComputedStyleX = undefined; function css(el, name, v) { var value = v; if (typeof name === 'object') { for (var i in name) { if (name.hasOwnProperty(i)) { css(el, i, name[i]); } } return undefined; } if (typeof value !== 'undefined') { if (typeof value === 'number') { value = value + 'px'; } el.style[name] = value; return undefined; } return getComputedStyleX(el, name); } function getClientPosition(elem) { var box = undefined; var x = undefined; var y = undefined; var doc = elem.ownerDocument; var body = doc.body; var docElem = doc && doc.documentElement; // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 box = elem.getBoundingClientRect(); // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin x = box.left; y = box.top; // In IE, most of the time, 2 extra pixels are added to the top and left // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and // IE6 standards mode, this border can be overridden by setting the // document element's border to zero -- thus, we cannot rely on the // offset always being 2 pixels. // In quirks mode, the offset can be determined by querying the body's // clientLeft/clientTop, but in standards mode, it is found by querying // the document element's clientLeft/clientTop. Since we already called // getClientBoundingRect we have already forced a reflow, so it is not // too expensive just to query them all. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 // 窗口边框标准是设 documentElement ,quirks 时设置 body // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 // 标准 ie 下 docElem.clientTop 就是 border-top // ie7 html 即窗口边框改变不了。永远为 2 // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 x -= docElem.clientLeft || body.clientLeft || 0; y -= docElem.clientTop || body.clientTop || 0; return { left: x, top: y }; } function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; // ie6,7,8 standard mode ret = d.documentElement[method]; if (typeof ret !== 'number') { // quirks mode ret = d.body[method]; } } return ret; } function getScrollLeft(w) { return getScroll(w); } function getScrollTop(w) { return getScroll(w, true); } function getOffset(el) { var pos = getClientPosition(el); var doc = el.ownerDocument; var w = doc.defaultView || doc.parentWindow; pos.left += getScrollLeft(w); pos.top += getScrollTop(w); return pos; } function _getComputedStyle(elem, name, cs) { var computedStyle = cs; var val = ''; var d = elem.ownerDocument; // https://github.com/kissyteam/kissy/issues/61 if (computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null)) { val = computedStyle.getPropertyValue(name) || computedStyle[name]; } return val; } var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); var RE_POS = /^(top|right|bottom|left)$/; var CURRENT_STYLE = 'currentStyle'; var RUNTIME_STYLE = 'runtimeStyle'; var LEFT = 'left'; var PX = 'px'; function _getComputedStyleIE(elem, name) { // currentStyle maybe null // http://msdn.microsoft.com/en-us/library/ms535231.aspx var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 // 在 ie 下不对,需要直接用 offset 方式 // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // If we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels // exclude left right for relativity if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { // Remember the original values var style = elem.style; var left = style[LEFT]; var rsLeft = elem[RUNTIME_STYLE][LEFT]; // prevent flashing of content elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; // Put in the new values to get a computed value out style[LEFT] = name === 'fontSize' ? '1em' : ret || 0; ret = style.pixelLeft + PX; // Revert the changed values style[LEFT] = left; elem[RUNTIME_STYLE][LEFT] = rsLeft; } return ret === '' ? 'auto' : ret; } if (typeof window !== 'undefined') { getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; } // 设置 elem 相对 elem.ownerDocument 的坐标 function setOffset(elem, offset) { // set position first, in-case top/left are set even on static elem if (css(elem, 'position') === 'static') { elem.style.position = 'relative'; } var preset = -9999; if ('left' in offset) { elem.style.left = preset + 'px'; } if ('top' in offset) { elem.style.top = preset + 'px'; } var old = getOffset(elem); var ret = {}; var key = undefined; for (key in offset) { if (offset.hasOwnProperty(key)) { ret[key] = preset + offset[key] - old[key]; } } css(elem, ret); } function each(arr, fn) { for (var i = 0; i < arr.length; i++) { fn(arr[i]); } } function isBorderBoxFn(elem) { return getComputedStyleX(elem, 'boxSizing') === 'border-box'; } var BOX_MODELS = ['margin', 'border', 'padding']; var CONTENT_INDEX = -1; var PADDING_INDEX = 2; var BORDER_INDEX = 1; var MARGIN_INDEX = 0; function swap(elem, options, callback) { var old = {}; var style = elem.style; var name = undefined; // Remember the old values, and insert the new ones for (name in options) { if (options.hasOwnProperty(name)) { old[name] = style[name]; style[name] = options[name]; } } callback.call(elem); // Revert the old values for (name in options) { if (options.hasOwnProperty(name)) { style[name] = old[name]; } } } function getPBMWidth(elem, props, which) { var value = 0; var prop = undefined; var j = undefined; var i = undefined; for (j = 0; j < props.length; j++) { prop = props[j]; if (prop) { for (i = 0; i < which.length; i++) { var cssProp = undefined; if (prop === 'border') { cssProp = prop + which[i] + 'Width'; } else { cssProp = prop + which[i]; } value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; } } } return value; } /** * A crude way of determining if an object is a window * @member util */ function isWindow(obj) { // must use == for ie8 /* eslint eqeqeq:0 */ return obj !== null && obj !== undefined && obj == obj.window; } var domUtils = {}; each(['Width', 'Height'], function (name) { domUtils['doc' + name] = function (refWin) { var d = refWin.document; return Math.max( // firefox chrome documentElement.scrollHeight< body.scrollHeight // ie standard mode : documentElement.scrollHeight> body.scrollHeight d.documentElement['scroll' + name], // quirks : documentElement.scrollHeight 最大等于可视窗口多一点? d.body['scroll' + name], domUtils['viewport' + name](d)); }; domUtils['viewport' + name] = function (win) { // pc browser includes scrollbar in window.innerWidth var prop = 'client' + name; var doc = win.document; var body = doc.body; var documentElement = doc.documentElement; var documentElementProp = documentElement[prop]; // 标准模式取 documentElement // backcompat 取 body return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp; }; }); /* 得到元素的大小信息 @param elem @param name @param {String} [extra] 'padding' : (css width) + padding 'border' : (css width) + padding + border 'margin' : (css width) + padding + border + margin */ function getWH(elem, name, ex) { var extra = ex; if (isWindow(elem)) { return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); } else if (elem.nodeType === 9) { return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); } var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem, computedStyle); var cssBoxValue = 0; if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) { borderBoxValue = undefined; // Fall back to computed then un computed css if necessary cssBoxValue = getComputedStyleX(elem, name); if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) { cssBoxValue = elem.style[name] || 0; } // Normalize '', auto, and prepare for extra cssBoxValue = parseFloat(cssBoxValue) || 0; } if (extra === undefined) { extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; } var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; var val = borderBoxValue || cssBoxValue; if (extra === CONTENT_INDEX) { if (borderBoxValueOrIsBorderBox) { return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle); } return cssBoxValue; } else if (borderBoxValueOrIsBorderBox) { if (extra === BORDER_INDEX) { return val; } return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle)); } return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle); } var cssShow = { position: 'absolute', visibility: 'hidden', display: 'block' }; // fix #119 : https://github.com/kissyteam/kissy/issues/119 function getWHIgnoreDisplay() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var val = undefined; var elem = args[0]; // in case elem is window // elem.offsetWidth === undefined if (elem.offsetWidth !== 0) { val = getWH.apply(undefined, args); } else { swap(elem, cssShow, function () { val = getWH.apply(undefined, args); }); } return val; } each(['width', 'height'], function (name) { var first = name.charAt(0).toUpperCase() + name.slice(1); domUtils['outer' + first] = function (el, includeMargin) { return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); }; var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; domUtils[name] = function (elem, v) { var val = v; if (val !== undefined) { if (elem) { var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem); if (isBorderBox) { val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); } return css(elem, name, val); } return undefined; } return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); }; }); function mix(to, from) { for (var i in from) { if (from.hasOwnProperty(i)) { to[i] = from[i]; } } return to; } var utils = { getWindow: function getWindow(node) { if (node && node.document && node.setTimeout) { return node; } var doc = node.ownerDocument || node; return doc.defaultView || doc.parentWindow; }, offset: function offset(el, value) { if (typeof value !== 'undefined') { setOffset(el, value); } else { return getOffset(el); } }, isWindow: isWindow, each: each, css: css, clone: function clone(obj) { var i = undefined; var ret = {}; for (i in obj) { if (obj.hasOwnProperty(i)) { ret[i] = obj[i]; } } var overflow = obj.overflow; if (overflow) { for (i in obj) { if (obj.hasOwnProperty(i)) { ret.overflow[i] = obj.overflow[i]; } } } return ret; }, mix: mix, getWindowScrollLeft: function getWindowScrollLeft(w) { return getScrollLeft(w); }, getWindowScrollTop: function getWindowScrollTop(w) { return getScrollTop(w); }, merge: function merge() { var ret = {}; for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } for (var i = 0; i < args.length; i++) { utils.mix(ret, args[i]); } return ret; }, viewportWidth: 0, viewportHeight: 0 }; mix(utils, domUtils); exports['default'] = utils; module.exports = exports['default']; /***/ }, /* 145 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(144); var _utils2 = _interopRequireDefault(_utils); /** * 得到会导致元素显示不全的祖先元素 */ function getOffsetParent(element) { // ie 这个也不是完全可行 /* <div style="width: 50px;height: 100px;overflow: hidden"> <div style="width: 50px;height: 100px;position: relative;" id="d6"> 元素 6 高 100px 宽 50px<br/> </div> </div> */ // element.offsetParent does the right thing in ie7 and below. Return parent with layout! // In other browsers it only includes elements with position absolute, relative or // fixed, not elements with overflow set to auto or scroll. // if (UA.ie && ieMode < 8) { // return element.offsetParent; // } // 统一的 offsetParent 方法 var doc = element.ownerDocument; var body = doc.body; var parent = undefined; var positionStyle = _utils2['default'].css(element, 'position'); var skipStatic = positionStyle === 'fixed' || positionStyle === 'absolute'; if (!skipStatic) { return element.nodeName.toLowerCase() === 'html' ? null : element.parentNode; } for (parent = element.parentNode; parent && parent !== body; parent = parent.parentNode) { positionStyle = _utils2['default'].css(parent, 'position'); if (positionStyle !== 'static') { return parent; } } return null; } exports['default'] = getOffsetParent; module.exports = exports['default']; /***/ }, /* 146 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(144); var _utils2 = _interopRequireDefault(_utils); var _getOffsetParent = __webpack_require__(145); var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); /** * 获得元素的显示部分的区域 */ function getVisibleRectForElement(element) { var visibleRect = { left: 0, right: Infinity, top: 0, bottom: Infinity }; var el = (0, _getOffsetParent2['default'])(element); var scrollX = undefined; var scrollY = undefined; var winSize = undefined; var doc = element.ownerDocument; var win = doc.defaultView || doc.parentWindow; var body = doc.body; var documentElement = doc.documentElement; // Determine the size of the visible rect by climbing the dom accounting for // all scrollable containers. while (el) { // clientWidth is zero for inline block elements in ie. if ((navigator.userAgent.indexOf('MSIE') === -1 || el.clientWidth !== 0) && ( // body may have overflow set on it, yet we still get the entire // viewport. In some browsers, el.offsetParent may be // document.documentElement, so check for that too. el !== body && el !== documentElement && _utils2['default'].css(el, 'overflow') !== 'visible')) { var pos = _utils2['default'].offset(el); // add border pos.left += el.clientLeft; pos.top += el.clientTop; visibleRect.top = Math.max(visibleRect.top, pos.top); visibleRect.right = Math.min(visibleRect.right, // consider area without scrollBar pos.left + el.clientWidth); visibleRect.bottom = Math.min(visibleRect.bottom, pos.top + el.clientHeight); visibleRect.left = Math.max(visibleRect.left, pos.left); } else if (el === body || el === documentElement) { break; } el = (0, _getOffsetParent2['default'])(el); } // Clip by window's viewport. scrollX = _utils2['default'].getWindowScrollLeft(win); scrollY = _utils2['default'].getWindowScrollTop(win); visibleRect.left = Math.max(visibleRect.left, scrollX); visibleRect.top = Math.max(visibleRect.top, scrollY); winSize = { width: _utils2['default'].viewportWidth(win), height: _utils2['default'].viewportHeight(win) }; visibleRect.right = Math.min(visibleRect.right, scrollX + winSize.width); visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + winSize.height); return visibleRect.top >= 0 && visibleRect.left >= 0 && visibleRect.bottom > visibleRect.top && visibleRect.right > visibleRect.left ? visibleRect : null; } exports['default'] = getVisibleRectForElement; module.exports = exports['default']; /***/ }, /* 147 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(144); var _utils2 = _interopRequireDefault(_utils); function adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) { var pos = _utils2['default'].clone(elFuturePos); var size = { width: elRegion.width, height: elRegion.height }; if (overflow.adjustX && pos.left < visibleRect.left) { pos.left = visibleRect.left; } // Left edge inside and right edge outside viewport, try to resize it. if (overflow.resizeWidth && pos.left >= visibleRect.left && pos.left + size.width > visibleRect.right) { size.width -= pos.left + size.width - visibleRect.right; } // Right edge outside viewport, try to move it. if (overflow.adjustX && pos.left + size.width > visibleRect.right) { // 保证左边界和可视区域左边界对齐 pos.left = Math.max(visibleRect.right - size.width, visibleRect.left); } // Top edge outside viewport, try to move it. if (overflow.adjustY && pos.top < visibleRect.top) { pos.top = visibleRect.top; } // Top edge inside and bottom edge outside viewport, try to resize it. if (overflow.resizeHeight && pos.top >= visibleRect.top && pos.top + size.height > visibleRect.bottom) { size.height -= pos.top + size.height - visibleRect.bottom; } // Bottom edge outside viewport, try to move it. if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) { // 保证上边界和可视区域上边界对齐 pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top); } return _utils2['default'].mix(pos, size); } exports['default'] = adjustForViewport; module.exports = exports['default']; /***/ }, /* 148 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(144); var _utils2 = _interopRequireDefault(_utils); function getRegion(node) { var offset = undefined; var w = undefined; var h = undefined; if (!_utils2['default'].isWindow(node) && node.nodeType !== 9) { offset = _utils2['default'].offset(node); w = _utils2['default'].outerWidth(node); h = _utils2['default'].outerHeight(node); } else { var win = _utils2['default'].getWindow(node); offset = { left: _utils2['default'].getWindowScrollLeft(win), top: _utils2['default'].getWindowScrollTop(win) }; w = _utils2['default'].viewportWidth(win); h = _utils2['default'].viewportHeight(win); } offset.width = w; offset.height = h; return offset; } exports['default'] = getRegion; module.exports = exports['default']; /***/ }, /* 149 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _getAlignOffset = __webpack_require__(150); var _getAlignOffset2 = _interopRequireDefault(_getAlignOffset); function getElFuturePos(elRegion, refNodeRegion, points, offset, targetOffset) { var xy = undefined; var diff = undefined; var p1 = undefined; var p2 = undefined; xy = { left: elRegion.left, top: elRegion.top }; p1 = (0, _getAlignOffset2['default'])(refNodeRegion, points[1]); p2 = (0, _getAlignOffset2['default'])(elRegion, points[0]); diff = [p2.left - p1.left, p2.top - p1.top]; return { left: xy.left - diff[0] + offset[0] - targetOffset[0], top: xy.top - diff[1] + offset[1] - targetOffset[1] }; } exports['default'] = getElFuturePos; module.exports = exports['default']; /***/ }, /* 150 */ /***/ function(module, exports) { /** * 获取 node 上的 align 对齐点 相对于页面的坐标 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function getAlignOffset(region, align) { var V = align.charAt(0); var H = align.charAt(1); var w = region.width; var h = region.height; var x = undefined; var y = undefined; x = region.left; y = region.top; if (V === 'c') { y += h / 2; } else if (V === 'b') { y += h; } if (H === 'c') { x += w / 2; } else if (H === 'r') { x += w; } return { left: x, top: y }; } exports['default'] = getAlignOffset; module.exports = exports['default']; /***/ }, /* 151 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _reactSlick = __webpack_require__(152); var _reactSlick2 = _interopRequireDefault(_reactSlick); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _objectAssign = __webpack_require__(184); var _objectAssign2 = _interopRequireDefault(_objectAssign); var AntCarousel = _react2['default'].createClass({ displayName: 'AntCarousel', getDefaultProps: function getDefaultProps() { return { dots: true, arrows: false }; }, render: function render() { var props = (0, _objectAssign2['default'])({}, this.props); if (props.effect === 'fade') { props.fade = true; props.draggable = false; } var className = 'ant-carousel'; if (props.vertical) { className = className + ' ant-carousel-vertical'; } return _react2['default'].createElement( 'div', { className: className }, _react2['default'].createElement(_reactSlick2['default'], props) ); } }); exports['default'] = AntCarousel; module.exports = exports['default']; /***/ }, /* 152 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(153); /***/ }, /* 153 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _innerSlider = __webpack_require__(154); var _objectAssign = __webpack_require__(157); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _json2mq = __webpack_require__(179); var _json2mq2 = _interopRequireDefault(_json2mq); var _reactResponsiveMixin = __webpack_require__(181); var _reactResponsiveMixin2 = _interopRequireDefault(_reactResponsiveMixin); var _defaultProps = __webpack_require__(162); var _defaultProps2 = _interopRequireDefault(_defaultProps); var Slider = _react2['default'].createClass({ displayName: 'Slider', mixins: [_reactResponsiveMixin2['default']], getInitialState: function getInitialState() { return { breakpoint: null }; }, componentDidMount: function componentDidMount() { var _this = this; if (this.props.responsive) { var breakpoints = this.props.responsive.map(function (breakpt) { return breakpt.breakpoint; }); breakpoints.sort(function (x, y) { return x - y; }); breakpoints.forEach(function (breakpoint, index) { var bQuery; if (index === 0) { bQuery = (0, _json2mq2['default'])({ minWidth: 0, maxWidth: breakpoint }); } else { bQuery = (0, _json2mq2['default'])({ minWidth: breakpoints[index - 1], maxWidth: breakpoint }); } _this.media(bQuery, function () { _this.setState({ breakpoint: breakpoint }); }); }); // Register media query for full screen. Need to support resize from small to large var query = (0, _json2mq2['default'])({ minWidth: breakpoints.slice(-1)[0] }); this.media(query, function () { _this.setState({ breakpoint: null }); }); } }, render: function render() { var _this2 = this; var settings; var newProps; if (this.state.breakpoint) { newProps = this.props.responsive.filter(function (resp) { return resp.breakpoint === _this2.state.breakpoint; }); settings = newProps[0].settings === 'unslick' ? 'unslick' : (0, _objectAssign2['default'])({}, this.props, newProps[0].settings); } else { settings = (0, _objectAssign2['default'])({}, _defaultProps2['default'], this.props); } if (settings === 'unslick') { // if 'unslick' responsive breakpoint setting used, just return the <Slider> tag nested HTML return _react2['default'].createElement( 'div', null, this.props.children ); } else { return _react2['default'].createElement( _innerSlider.InnerSlider, settings, this.props.children ); } } }); module.exports = Slider; /***/ }, /* 154 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _mixinsEventHandlers = __webpack_require__(155); var _mixinsEventHandlers2 = _interopRequireDefault(_mixinsEventHandlers); var _mixinsHelpers = __webpack_require__(158); var _mixinsHelpers2 = _interopRequireDefault(_mixinsHelpers); var _initialState = __webpack_require__(161); var _initialState2 = _interopRequireDefault(_initialState); var _defaultProps = __webpack_require__(162); var _defaultProps2 = _interopRequireDefault(_defaultProps); var _classnames = __webpack_require__(163); var _classnames2 = _interopRequireDefault(_classnames); var _track = __webpack_require__(164); var _dots = __webpack_require__(177); var _arrows = __webpack_require__(178); var InnerSlider = _react2['default'].createClass({ displayName: 'InnerSlider', mixins: [_mixinsHelpers2['default'], _mixinsEventHandlers2['default']], getInitialState: function getInitialState() { return _initialState2['default']; }, getDefaultProps: function getDefaultProps() { return _defaultProps2['default']; }, componentWillMount: function componentWillMount() { if (this.props.init) { this.props.init(); } this.setState({ mounted: true }); var lazyLoadedList = []; for (var i = 0; i < this.props.children.length; i++) { if (i >= this.state.currentSlide && i < this.state.currentSlide + this.props.slidesToShow) { lazyLoadedList.push(i); } } if (this.props.lazyLoad && this.state.lazyLoadedList.length === 0) { this.setState({ lazyLoadedList: lazyLoadedList }); } }, componentDidMount: function componentDidMount() { // Hack for autoplay -- Inspect Later this.initialize(this.props); this.adaptHeight(); window.addEventListener('resize', this.onWindowResized); }, componentWillUnmount: function componentWillUnmount() { window.removeEventListener('resize', this.onWindowResized); if (this.state.autoPlayTimer) { window.clearTimeout(this.state.autoPlayTimer); } }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { this.update(nextProps); }, componentDidUpdate: function componentDidUpdate() { this.adaptHeight(); }, onWindowResized: function onWindowResized() { this.update(this.props); }, render: function render() { var className = (0, _classnames2['default'])('slick-initialized', 'slick-slider', this.props.className); var trackProps = { fade: this.props.fade, cssEase: this.props.cssEase, speed: this.props.speed, infinite: this.props.infinite, centerMode: this.props.centerMode, currentSlide: this.state.currentSlide, lazyLoad: this.props.lazyLoad, lazyLoadedList: this.state.lazyLoadedList, rtl: this.props.rtl, slideWidth: this.state.slideWidth, slidesToShow: this.props.slidesToShow, slideCount: this.state.slideCount, trackStyle: this.state.trackStyle, variableWidth: this.props.variableWidth }; var dots; if (this.props.dots === true && this.state.slideCount > this.props.slidesToShow) { var dotProps = { dotsClass: this.props.dotsClass, slideCount: this.state.slideCount, slidesToShow: this.props.slidesToShow, currentSlide: this.state.currentSlide, slidesToScroll: this.props.slidesToScroll, clickHandler: this.changeSlide }; dots = _react2['default'].createElement(_dots.Dots, dotProps); } var prevArrow, nextArrow; var arrowProps = { infinite: this.props.infinite, centerMode: this.props.centerMode, currentSlide: this.state.currentSlide, slideCount: this.state.slideCount, slidesToShow: this.props.slidesToShow, prevArrow: this.props.prevArrow, nextArrow: this.props.nextArrow, clickHandler: this.changeSlide }; if (this.props.arrows) { prevArrow = _react2['default'].createElement(_arrows.PrevArrow, arrowProps); nextArrow = _react2['default'].createElement(_arrows.NextArrow, arrowProps); } return _react2['default'].createElement( 'div', { className: className }, _react2['default'].createElement( 'div', { ref: 'list', className: 'slick-list', onMouseDown: this.swipeStart, onMouseMove: this.state.dragging ? this.swipeMove : null, onMouseUp: this.swipeEnd, onMouseLeave: this.state.dragging ? this.swipeEnd : null, onTouchStart: this.swipeStart, onTouchMove: this.state.dragging ? this.swipeMove : null, onTouchEnd: this.swipeEnd, onTouchCancel: this.state.dragging ? this.swipeEnd : null }, _react2['default'].createElement( _track.Track, _extends({ ref: 'track' }, trackProps), this.props.children ) ), prevArrow, nextArrow, dots ); } }); exports.InnerSlider = InnerSlider; /***/ }, /* 155 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _trackHelper = __webpack_require__(156); var _objectAssign = __webpack_require__(157); var _objectAssign2 = _interopRequireDefault(_objectAssign); var EventHandlers = { // Event handler for previous and next changeSlide: function changeSlide(options) { var indexOffset, slideOffset, unevenOffset, targetSlide; unevenOffset = this.state.slideCount % this.props.slidesToScroll !== 0; indexOffset = unevenOffset ? 0 : (this.state.slideCount - this.state.currentSlide) % this.props.slidesToScroll; if (options.message === 'previous') { slideOffset = indexOffset === 0 ? this.props.slidesToScroll : this.props.slidesToShow - indexOffset; targetSlide = this.state.currentSlide - slideOffset; } else if (options.message === 'next') { slideOffset = indexOffset === 0 ? this.props.slidesToScroll : indexOffset; targetSlide = this.state.currentSlide + slideOffset; } else if (options.message === 'dots') { // Click on dots targetSlide = options.index * options.slidesToScroll; if (targetSlide === options.currentSlide) { return; } } this.slideHandler(targetSlide); }, // Accessiblity handler for previous and next keyHandler: function keyHandler(e) {}, // Focus on selecting a slide (click handler on track) selectHandler: function selectHandler(e) {}, swipeStart: function swipeStart(e) { var touches, posX, posY; if (this.props.swipe === false || 'ontouchend' in document && this.props.swipe === false) { return; } else if (this.props.draggable === false && e.type.indexOf('mouse') !== -1) { return; } posX = e.touches !== undefined ? e.touches[0].pageX : e.clientX; posY = e.touches !== undefined ? e.touches[0].pageY : e.clientY; this.setState({ dragging: true, touchObject: { startX: posX, startY: posY, curX: posX, curY: posY } }); }, swipeMove: function swipeMove(e) { if (!this.state.dragging) { return; } if (this.state.animating) { return; } var swipeLeft; var curLeft, positionOffset; var touchObject = this.state.touchObject; curLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2['default'])({ slideIndex: this.state.currentSlide, trackRef: this.refs.track }, this.props, this.state)); touchObject.curX = e.touches ? e.touches[0].pageX : e.clientX; touchObject.curY = e.touches ? e.touches[0].pageY : e.clientY; touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(touchObject.curX - touchObject.startX, 2))); positionOffset = (this.props.rtl === false ? 1 : -1) * (touchObject.curX > touchObject.startX ? 1 : -1); var currentSlide = this.state.currentSlide; var dotCount = Math.ceil(this.state.slideCount / this.props.slidesToScroll); var swipeDirection = this.swipeDirection(this.state.touchObject); var touchSwipeLength = touchObject.swipeLength; if (this.props.infinite === false) { if (currentSlide === 0 && swipeDirection === 'right' || currentSlide + 1 >= dotCount && swipeDirection === 'left') { touchSwipeLength = touchObject.swipeLength * this.props.edgeFriction; if (this.state.edgeDragged === false && this.props.edgeEvent) { this.props.edgeEvent(swipeDirection); this.setState({ edgeDragged: true }); } } } if (this.state.swiped === false && this.props.swipeEvent) { this.props.swipeEvent(swipeDirection); this.setState({ swiped: true }); } swipeLeft = curLeft + touchSwipeLength * positionOffset; this.setState({ touchObject: touchObject, swipeLeft: swipeLeft, trackStyle: (0, _trackHelper.getTrackCSS)((0, _objectAssign2['default'])({ left: swipeLeft }, this.props, this.state)) }); if (Math.abs(touchObject.curX - touchObject.startX) < Math.abs(touchObject.curY - touchObject.startY) * 0.8) { return; } if (touchObject.swipeLength > 4) { e.preventDefault(); } }, swipeEnd: function swipeEnd(e) { if (!this.state.dragging) { return; } var touchObject = this.state.touchObject; var minSwipe = this.state.listWidth / this.props.touchThreshold; var swipeDirection = this.swipeDirection(touchObject); // reset the state of touch related state variables. this.setState({ dragging: false, edgeDragged: false, swiped: false, swipeLeft: null, touchObject: {} }); // Fix for #13 if (!touchObject.swipeLength) { return; } if (touchObject.swipeLength > minSwipe) { e.preventDefault(); if (swipeDirection === 'left') { this.slideHandler(this.state.currentSlide + this.props.slidesToScroll); } else if (swipeDirection === 'right') { this.slideHandler(this.state.currentSlide - this.props.slidesToScroll); } else { this.slideHandler(this.state.currentSlide); } } else { // Adjust the track back to it's original position. var currentLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2['default'])({ slideIndex: this.state.currentSlide, trackRef: this.refs.track }, this.props, this.state)); this.setState({ trackStyle: (0, _trackHelper.getTrackAnimateCSS)((0, _objectAssign2['default'])({ left: currentLeft }, this.props, this.state)) }); } } }; exports['default'] = EventHandlers; module.exports = exports['default']; /***/ }, /* 156 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var checkSpecKeys = function checkSpecKeys(spec, keysArray) { return keysArray.reduce(function (value, key) { return value && spec.hasOwnProperty(key); }, true) ? null : console.error('Keys Missing', spec); }; var getTrackCSS = function getTrackCSS(spec) { checkSpecKeys(spec, ['left', 'variableWidth', 'slideCount', 'slidesToShow', 'slideWidth']); var trackWidth; if (spec.variableWidth) { trackWidth = (spec.slideCount + 2 * spec.slidesToShow) * spec.slideWidth; } else if (spec.centerMode) { trackWidth = (spec.slideCount + 2 * (spec.slidesToShow + 1)) * spec.slideWidth; } else { trackWidth = (spec.slideCount + 2 * spec.slidesToShow) * spec.slideWidth; } var style = { opacity: 1, width: trackWidth, WebkitTransform: 'translate3d(' + spec.left + 'px, 0px, 0px)', transform: 'translate3d(' + spec.left + 'px, 0px, 0px)', transition: '', WebkitTransition: '', msTransform: 'translateX(' + spec.left + 'px)' }; // Fallback for IE8 if (!window.addEventListener && window.attachEvent) { style.marginLeft = spec.left + 'px'; } return style; }; exports.getTrackCSS = getTrackCSS; var getTrackAnimateCSS = function getTrackAnimateCSS(spec) { checkSpecKeys(spec, ['left', 'variableWidth', 'slideCount', 'slidesToShow', 'slideWidth', 'speed', 'cssEase']); var style = getTrackCSS(spec); // useCSS is true by default so it can be undefined style.WebkitTransition = '-webkit-transform ' + spec.speed + 'ms ' + spec.cssEase; style.transition = 'transform ' + spec.speed + 'ms ' + spec.cssEase; return style; }; exports.getTrackAnimateCSS = getTrackAnimateCSS; var getTrackLeft = function getTrackLeft(spec) { checkSpecKeys(spec, ['slideIndex', 'trackRef', 'infinite', 'centerMode', 'slideCount', 'slidesToShow', 'slidesToScroll', 'slideWidth', 'listWidth', 'variableWidth']); var slideOffset = 0; var targetLeft; var targetSlide; if (spec.fade) { return 0; } if (spec.infinite) { if (spec.slideCount > spec.slidesToShow) { slideOffset = spec.slideWidth * spec.slidesToShow * -1; } if (spec.slideCount % spec.slidesToScroll !== 0) { if (spec.slideIndex + spec.slidesToScroll > spec.slideCount && spec.slideCount > spec.slidesToShow) { if (spec.slideIndex > spec.slideCount) { slideOffset = (spec.slidesToShow - (spec.slideIndex - spec.slideCount)) * spec.slideWidth * -1; } else { slideOffset = spec.slideCount % spec.slidesToScroll * spec.slideWidth * -1; } } } } if (spec.centerMode) { if (spec.infinite) { slideOffset += spec.slideWidth * Math.floor(spec.slidesToShow / 2); } else { slideOffset = spec.slideWidth * Math.floor(spec.slidesToShow / 2); } } targetLeft = spec.slideIndex * spec.slideWidth * -1 + slideOffset; if (spec.variableWidth === true) { var targetSlideIndex; if (spec.slideCount <= spec.slidesToShow || spec.infinite === false) { targetSlide = spec.trackRef.getDOMNode().childNodes[spec.slideIndex]; } else { targetSlideIndex = spec.slideIndex + spec.slidesToShow; targetSlide = spec.trackRef.getDOMNode().childNodes[targetSlideIndex]; } targetLeft = targetSlide ? targetSlide.offsetLeft * -1 : 0; if (spec.centerMode === true) { if (spec.infinite === false) { targetSlide = spec.trackRef.getDOMNode().children[spec.slideIndex]; } else { targetSlide = spec.trackRef.getDOMNode().children[spec.slideIndex + spec.slidesToShow + 1]; } targetLeft = targetSlide ? targetSlide.offsetLeft * -1 : 0; targetLeft += (spec.listWidth - targetSlide.offsetWidth) / 2; } } return targetLeft; }; exports.getTrackLeft = getTrackLeft; /***/ }, /* 157 */ /***/ function(module, exports) { 'use strict'; function ToObject(val) { if (val == null) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } module.exports = Object.assign || function (target, source) { var from; var keys; var to = ToObject(target); for (var s = 1; s < arguments.length; s++) { from = arguments[s]; keys = Object.keys(Object(from)); for (var i = 0; i < keys.length; i++) { to[keys[i]] = from[keys[i]]; } } return to; }; /***/ }, /* 158 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _reactLibReactTransitionEvents = __webpack_require__(159); var _reactLibReactTransitionEvents2 = _interopRequireDefault(_reactLibReactTransitionEvents); var _trackHelper = __webpack_require__(156); var _objectAssign = __webpack_require__(157); var _objectAssign2 = _interopRequireDefault(_objectAssign); var helpers = { initialize: function initialize(props) { var slideCount = _react2['default'].Children.count(props.children); var listWidth = this.getWidth(this.refs.list.getDOMNode()); var trackWidth = this.getWidth(this.refs.track.getDOMNode()); var slideWidth = this.getWidth(this.getDOMNode()) / props.slidesToShow; var currentSlide = props.rtl ? slideCount - 1 - props.initialSlide : props.initialSlide; this.setState({ slideCount: slideCount, slideWidth: slideWidth, listWidth: listWidth, trackWidth: trackWidth, currentSlide: currentSlide }, function () { var targetLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2['default'])({ slideIndex: this.state.currentSlide, trackRef: this.refs.track }, props, this.state)); // getCSS function needs previously set state var trackStyle = (0, _trackHelper.getTrackCSS)((0, _objectAssign2['default'])({ left: targetLeft }, props, this.state)); this.setState({ trackStyle: trackStyle }); this.autoPlay(); // once we're set up, trigger the initial autoplay. }); }, update: function update(props) { // This method has mostly same code as initialize method. // Refactor it var slideCount = _react2['default'].Children.count(props.children); var listWidth = this.getWidth(this.refs.list.getDOMNode()); var trackWidth = this.getWidth(this.refs.track.getDOMNode()); var slideWidth = this.getWidth(this.getDOMNode()) / props.slidesToShow; this.setState({ slideCount: slideCount, slideWidth: slideWidth, listWidth: listWidth, trackWidth: trackWidth }, function () { var targetLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2['default'])({ slideIndex: this.state.currentSlide, trackRef: this.refs.track }, props, this.state)); // getCSS function needs previously set state var trackStyle = (0, _trackHelper.getTrackCSS)((0, _objectAssign2['default'])({ left: targetLeft }, props, this.state)); this.setState({ trackStyle: trackStyle }); }); }, getWidth: function getWidth(elem) { return elem.getBoundingClientRect().width || elem.offsetWidth; }, adaptHeight: function adaptHeight() { if (this.props.adaptiveHeight) { var selector = '[data-index="' + this.state.currentSlide + '"]'; if (this.refs.list) { var slickList = this.refs.list.getDOMNode(); slickList.style.height = slickList.querySelector(selector).offsetHeight + 'px'; } } }, slideHandler: function slideHandler(index) { var _this = this; // Functionality of animateSlide and postSlide is merged into this function // console.log('slideHandler', index); var targetSlide, currentSlide; var targetLeft, currentLeft; var callback; if (this.state.currentSlide === index) { return; } if (this.props.fade) { currentSlide = this.state.currentSlide; // Shifting targetSlide back into the range if (index < 0) { targetSlide = index + this.state.slideCount; } else if (index >= this.state.slideCount) { targetSlide = index - this.state.slideCount; } else { targetSlide = index; } if (this.props.lazyLoad && this.state.lazyLoadedList.indexOf(targetSlide) < 0) { this.setState({ lazyLoadedList: this.state.lazyLoadedList.concat(targetSlide) }); } callback = function () { _this.setState({ animating: false }); if (_this.props.afterChange) { _this.props.afterChange(currentSlide); } _reactLibReactTransitionEvents2['default'].removeEndEventListener(_this.refs.track.getDOMNode().children[currentSlide], callback); }; this.setState({ animating: true, currentSlide: targetSlide }, function () { _reactLibReactTransitionEvents2['default'].addEndEventListener(this.refs.track.getDOMNode().children[currentSlide], callback); }); if (this.props.beforeChange) { this.props.beforeChange(this.state.currentSlide, currentSlide); } this.autoPlay(); return; } targetSlide = index; if (targetSlide < 0) { if (this.props.infinite === false) { currentSlide = 0; } else if (this.state.slideCount % this.props.slidesToScroll !== 0) { currentSlide = this.state.slideCount - this.state.slideCount % this.props.slidesToScroll; } else { currentSlide = this.state.slideCount + targetSlide; } } else if (targetSlide >= this.state.slideCount) { if (this.props.infinite === false) { currentSlide = this.state.slideCount - this.props.slidesToShow; } else if (this.state.slideCount % this.props.slidesToScroll !== 0) { currentSlide = 0; } else { currentSlide = targetSlide - this.state.slideCount; } } else { currentSlide = targetSlide; } targetLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2['default'])({ slideIndex: targetSlide, trackRef: this.refs.track }, this.props, this.state)); currentLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2['default'])({ slideIndex: currentSlide, trackRef: this.refs.track }, this.props, this.state)); if (this.props.infinite === false) { targetLeft = currentLeft; } if (this.props.beforeChange) { this.props.beforeChange(this.state.currentSlide, currentSlide); } if (this.props.lazyLoad) { var loaded = true; var slidesToLoad = []; for (var i = targetSlide; i < targetSlide + this.props.slidesToShow; i++) { loaded = loaded && this.state.lazyLoadedList.indexOf(i) >= 0; if (!loaded) { slidesToLoad.push(i); } } if (!loaded) { this.setState({ lazyLoadedList: this.state.lazyLoadedList.concat(slidesToLoad) }); } } // Slide Transition happens here. // animated transition happens to target Slide and // non - animated transition happens to current Slide // If CSS transitions are false, directly go the current slide. if (this.props.useCSS === false) { this.setState({ currentSlide: currentSlide, trackStyle: (0, _trackHelper.getTrackCSS)((0, _objectAssign2['default'])({ left: currentLeft }, this.props, this.state)) }, function () { if (this.props.afterChange) { this.props.afterChange(currentSlide); } }); } else { var nextStateChanges = { animating: false, currentSlide: currentSlide, trackStyle: (0, _trackHelper.getTrackCSS)((0, _objectAssign2['default'])({ left: currentLeft }, this.props, this.state)), swipeLeft: null }; callback = function () { _this.setState(nextStateChanges); if (_this.props.afterChange) { _this.props.afterChange(currentSlide); } _reactLibReactTransitionEvents2['default'].removeEndEventListener(_this.refs.track.getDOMNode(), callback); }; this.setState({ animating: true, currentSlide: targetSlide, trackStyle: (0, _trackHelper.getTrackAnimateCSS)((0, _objectAssign2['default'])({ left: targetLeft }, this.props, this.state)) }, function () { _reactLibReactTransitionEvents2['default'].addEndEventListener(this.refs.track.getDOMNode(), callback); }); } this.autoPlay(); }, swipeDirection: function swipeDirection(touchObject) { var xDist, yDist, r, swipeAngle; xDist = touchObject.startX - touchObject.curX; yDist = touchObject.startY - touchObject.curY; r = Math.atan2(yDist, xDist); swipeAngle = Math.round(r * 180 / Math.PI); if (swipeAngle < 0) { swipeAngle = 360 - Math.abs(swipeAngle); } if (swipeAngle <= 45 && swipeAngle >= 0 || swipeAngle <= 360 && swipeAngle >= 315) { return this.props.rtl === false ? 'left' : 'right'; } if (swipeAngle >= 135 && swipeAngle <= 225) { return this.props.rtl === false ? 'right' : 'left'; } return 'vertical'; }, autoPlay: function autoPlay() { var _this2 = this; var play = function play() { if (_this2.state.mounted) { _this2.slideHandler(_this2.state.currentSlide + _this2.props.slidesToScroll); } }; if (this.props.autoplay) { window.clearTimeout(this.state.autoPlayTimer); this.setState({ autoPlayTimer: window.setTimeout(play, this.props.autoplaySpeed) }); } } }; exports['default'] = helpers; module.exports = exports['default']; /***/ }, /* 159 */ /***/ function(module, exports, __webpack_require__) { /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ReactTransitionEvents */ 'use strict'; var ExecutionEnvironment = __webpack_require__(160); /** * EVENT_NAME_MAP is used to determine which event fired when a * transition/animation ends, based on the style property used to * define that event. */ var EVENT_NAME_MAP = { transitionend: { 'transition': 'transitionend', 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'mozTransitionEnd', 'OTransition': 'oTransitionEnd', 'msTransition': 'MSTransitionEnd' }, animationend: { 'animation': 'animationend', 'WebkitAnimation': 'webkitAnimationEnd', 'MozAnimation': 'mozAnimationEnd', 'OAnimation': 'oAnimationEnd', 'msAnimation': 'MSAnimationEnd' } }; var endEvents = []; function detectEvents() { var testEl = document.createElement('div'); var style = testEl.style; // On some platforms, in particular some releases of Android 4.x, // the un-prefixed "animation" and "transition" properties are defined on the // style object but the events that fire will still be prefixed, so we need // to check if the un-prefixed events are useable, and if not remove them // from the map if (!('AnimationEvent' in window)) { delete EVENT_NAME_MAP.animationend.animation; } if (!('TransitionEvent' in window)) { delete EVENT_NAME_MAP.transitionend.transition; } for (var baseEventName in EVENT_NAME_MAP) { var baseEvents = EVENT_NAME_MAP[baseEventName]; for (var styleName in baseEvents) { if (styleName in style) { endEvents.push(baseEvents[styleName]); break; } } } } if (ExecutionEnvironment.canUseDOM) { detectEvents(); } // We use the raw {add|remove}EventListener() call because EventListener // does not know how to remove event listeners and we really should // clean up. Also, these events are not triggered in older browsers // so we should be A-OK here. function addEventListener(node, eventName, eventListener) { node.addEventListener(eventName, eventListener, false); } function removeEventListener(node, eventName, eventListener) { node.removeEventListener(eventName, eventListener, false); } var ReactTransitionEvents = { addEndEventListener: function(node, eventListener) { if (endEvents.length === 0) { // If CSS transitions are not supported, trigger an "end animation" // event immediately. window.setTimeout(eventListener, 0); return; } endEvents.forEach(function(endEvent) { addEventListener(node, endEvent, eventListener); }); }, removeEndEventListener: function(node, eventListener) { if (endEvents.length === 0) { return; } endEvents.forEach(function(endEvent) { removeEventListener(node, endEvent, eventListener); }); } }; module.exports = ReactTransitionEvents; /***/ }, /* 160 */ /***/ function(module, exports) { /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ExecutionEnvironment */ /*jslint evil: true */ "use strict"; var canUseDOM = !!( (typeof window !== 'undefined' && window.document && window.document.createElement) ); /** * Simple, lightweight module assisting with the detection and context of * Worker. Helps avoid circular dependencies and allows code to reason about * whether or not they are in a Worker, even if they never include the main * `ReactWorker` dependency. */ var ExecutionEnvironment = { canUseDOM: canUseDOM, canUseWorkers: typeof Worker !== 'undefined', canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), canUseViewport: canUseDOM && !!window.screen, isInWorker: !canUseDOM // For now, this is true - might change in the future. }; module.exports = ExecutionEnvironment; /***/ }, /* 161 */ /***/ function(module, exports) { "use strict"; var initialState = { animating: false, dragging: false, autoPlayTimer: null, currentDirection: 0, currentLeft: null, currentSlide: 0, direction: 1, // listWidth: null, // listHeight: null, // loadIndex: 0, slideCount: null, slideWidth: null, // sliding: false, // slideOffset: 0, swipeLeft: null, touchObject: { startX: 0, startY: 0, curX: 0, curY: 0 }, lazyLoadedList: [], // added for react initialized: false, edgeDragged: false, swiped: false, // used by swipeEvent. differentites between touch and swipe. trackStyle: {}, trackWidth: 0 // Removed // transformsEnabled: false, // $nextArrow: null, // $prevArrow: null, // $dots: null, // $list: null, // $slideTrack: null, // $slides: null, }; module.exports = initialState; /***/ }, /* 162 */ /***/ function(module, exports) { 'use strict'; var defaultProps = { className: '', // accessibility: true, adaptiveHeight: false, arrows: true, autoplay: false, autoplaySpeed: 3000, centerMode: false, centerPadding: '50px', cssEase: 'ease', dots: false, dotsClass: 'slick-dots', draggable: true, easing: 'linear', edgeFriction: 0.35, fade: false, focusOnSelect: false, infinite: true, initialSlide: 0, lazyLoad: false, responsive: null, rtl: false, slide: 'div', slidesToShow: 1, slidesToScroll: 1, speed: 500, swipe: true, swipeToSlide: false, touchMove: true, touchThreshold: 5, useCSS: true, variableWidth: false, vertical: false, // waitForAnimate: true, afterChange: null, beforeChange: null, edgeEvent: null, init: null, swipeEvent: null, // nextArrow, prevArrow are react componets nextArrow: null, prevArrow: null }; module.exports = defaultProps; /***/ }, /* 163 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/*! Copyright (c) 2015 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ /* global define */ (function () { 'use strict'; var hasOwn = {}.hasOwnProperty; function classNames () { var classes = ''; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (!arg) continue; var argType = typeof arg; if (argType === 'string' || argType === 'number') { classes += ' ' + arg; } else if (Array.isArray(arg)) { classes += ' ' + classNames.apply(null, arg); } else if (argType === 'object') { for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes += ' ' + key; } } } } return classes.substr(1); } if (typeof module !== 'undefined' && module.exports) { module.exports = classNames; } else if (true) { // register as 'classnames', consistent with npm package name !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { return classNames; }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else { window.classNames = classNames; } }()); /***/ }, /* 164 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _reactLibCloneWithProps = __webpack_require__(165); var _reactLibCloneWithProps2 = _interopRequireDefault(_reactLibCloneWithProps); var _objectAssign = __webpack_require__(157); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _classnames = __webpack_require__(163); var _classnames2 = _interopRequireDefault(_classnames); var getSlideClasses = function getSlideClasses(spec) { var slickActive, slickCenter, slickCloned; var centerOffset, index; if (spec.rtl) { index = spec.slideCount - 1 - spec.index; console.log(); } else { index = spec.index; } slickCloned = index < 0 || index >= spec.slideCount; if (spec.centerMode) { centerOffset = Math.floor(spec.slidesToShow / 2); slickCenter = spec.currentSlide === index; if (index > spec.currentSlide - centerOffset - 1 && index <= spec.currentSlide + centerOffset) { slickActive = true; } } else { slickActive = spec.currentSlide <= index && index < spec.currentSlide + spec.slidesToShow; } return (0, _classnames2['default'])({ 'slick-slide': true, 'slick-active': slickActive, 'slick-center': slickCenter, 'slick-cloned': slickCloned }); }; var getSlideStyle = function getSlideStyle(spec) { var style = {}; if (spec.variableWidth === undefined || spec.variableWidth === false) { style.width = spec.slideWidth; } if (spec.fade) { style.position = 'relative'; style.left = -spec.index * spec.slideWidth; style.opacity = spec.currentSlide === spec.index ? 1 : 0; style.transition = 'opacity ' + spec.speed + 'ms ' + spec.cssEase; style.WebkitTransition = 'opacity ' + spec.speed + 'ms ' + spec.cssEase; } return style; }; var renderSlides = function renderSlides(spec) { var key; var slides = []; var preCloneSlides = []; var postCloneSlides = []; var count = _react2['default'].Children.count(spec.children); var child; _react2['default'].Children.forEach(spec.children, function (elem, index) { if (!spec.lazyLoad | (spec.lazyLoad && spec.lazyLoadedList.indexOf(index) >= 0)) { child = elem; } else { child = _react2['default'].createElement('div', null); } var childStyle = getSlideStyle((0, _objectAssign2['default'])({}, spec, { index: index })); slides.push((0, _reactLibCloneWithProps2['default'])(child, { key: index, 'data-index': index, className: getSlideClasses((0, _objectAssign2['default'])({ index: index }, spec)), style: childStyle })); // variableWidth doesn't wrap properly. if (spec.infinite && spec.fade === false) { var infiniteCount = spec.variableWidth ? spec.slidesToShow + 1 : spec.slidesToShow; if (index >= count - infiniteCount) { key = -(count - index); preCloneSlides.push((0, _reactLibCloneWithProps2['default'])(child, { key: key, 'data-index': key, className: getSlideClasses((0, _objectAssign2['default'])({ index: key }, spec)), style: childStyle })); } if (index < infiniteCount) { key = count + index; postCloneSlides.push((0, _reactLibCloneWithProps2['default'])(child, { key: key, 'data-index': key, className: getSlideClasses((0, _objectAssign2['default'])({ index: key }, spec)), style: childStyle })); } } }); if (spec.rtl) { return preCloneSlides.concat(slides, postCloneSlides).reverse(); } else { return preCloneSlides.concat(slides, postCloneSlides); } }; var Track = _react2['default'].createClass({ displayName: 'Track', render: function render() { var slides = renderSlides(this.props); return _react2['default'].createElement( 'div', { className: 'slick-track', style: this.props.trackStyle }, slides ); } }); exports.Track = Track; /***/ }, /* 165 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @typechecks static-only * @providesModule cloneWithProps */ 'use strict'; var ReactElement = __webpack_require__(167); var ReactPropTransferer = __webpack_require__(174); var keyOf = __webpack_require__(176); var warning = __webpack_require__(171); var CHILDREN_PROP = keyOf({children: null}); /** * Sometimes you want to change the props of a child passed to you. Usually * this is to add a CSS class. * * @param {ReactElement} child child element you'd like to clone * @param {object} props props you'd like to modify. className and style will be * merged automatically. * @return {ReactElement} a clone of child with props merged in. */ function cloneWithProps(child, props) { if ("production" !== process.env.NODE_ENV) { ("production" !== process.env.NODE_ENV ? warning( !child.ref, 'You are calling cloneWithProps() on a child with a ref. This is ' + 'dangerous because you\'re creating a new child which will not be ' + 'added as a ref to its parent.' ) : null); } var newProps = ReactPropTransferer.mergeProps(props, child.props); // Use `child.props.children` if it is provided. if (!newProps.hasOwnProperty(CHILDREN_PROP) && child.props.hasOwnProperty(CHILDREN_PROP)) { newProps.children = child.props.children; } // The current API doesn't retain _owner and _context, which is why this // doesn't use ReactElement.cloneAndReplaceProps. return ReactElement.createElement(child.type, newProps); } module.exports = cloneWithProps; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(166))) /***/ }, /* 166 */ /***/ function(module, exports) { // shim for using process in browser var process = module.exports = {}; var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = setTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; clearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { setTimeout(drainQueue, 0); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }, /* 167 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ReactElement */ 'use strict'; var ReactContext = __webpack_require__(168); var ReactCurrentOwner = __webpack_require__(173); var assign = __webpack_require__(169); var warning = __webpack_require__(171); var RESERVED_PROPS = { key: true, ref: true }; /** * Warn for mutations. * * @internal * @param {object} object * @param {string} key */ function defineWarningProperty(object, key) { Object.defineProperty(object, key, { configurable: false, enumerable: true, get: function() { if (!this._store) { return null; } return this._store[key]; }, set: function(value) { ("production" !== process.env.NODE_ENV ? warning( false, 'Don\'t set the %s property of the React element. Instead, ' + 'specify the correct value when initially creating the element.', key ) : null); this._store[key] = value; } }); } /** * This is updated to true if the membrane is successfully created. */ var useMutationMembrane = false; /** * Warn for mutations. * * @internal * @param {object} element */ function defineMutationMembrane(prototype) { try { var pseudoFrozenProperties = { props: true }; for (var key in pseudoFrozenProperties) { defineWarningProperty(prototype, key); } useMutationMembrane = true; } catch (x) { // IE will fail on defineProperty } } /** * Base constructor for all React elements. This is only used to make this * work with a dynamic instanceof check. Nothing should live on this prototype. * * @param {*} type * @param {string|object} ref * @param {*} key * @param {*} props * @internal */ var ReactElement = function(type, key, ref, owner, context, props) { // Built-in properties that belong on the element this.type = type; this.key = key; this.ref = ref; // Record the component responsible for creating this element. this._owner = owner; // TODO: Deprecate withContext, and then the context becomes accessible // through the owner. this._context = context; if ("production" !== process.env.NODE_ENV) { // The validation flag and props are currently mutative. We put them on // an external backing store so that we can freeze the whole object. // This can be replaced with a WeakMap once they are implemented in // commonly used development environments. this._store = {props: props, originalProps: assign({}, props)}; // To make comparing ReactElements easier for testing purposes, we make // the validation flag non-enumerable (where possible, which should // include every environment we run tests in), so the test framework // ignores it. try { Object.defineProperty(this._store, 'validated', { configurable: false, enumerable: false, writable: true }); } catch (x) { } this._store.validated = false; // We're not allowed to set props directly on the object so we early // return and rely on the prototype membrane to forward to the backing // store. if (useMutationMembrane) { Object.freeze(this); return; } } this.props = props; }; // We intentionally don't expose the function on the constructor property. // ReactElement should be indistinguishable from a plain object. ReactElement.prototype = { _isReactElement: true }; if ("production" !== process.env.NODE_ENV) { defineMutationMembrane(ReactElement.prototype); } ReactElement.createElement = function(type, config, children) { var propName; // Reserved names are extracted var props = {}; var key = null; var ref = null; if (config != null) { ref = config.ref === undefined ? null : config.ref; key = config.key === undefined ? null : '' + config.key; // Remaining properties are added to a new props object for (propName in config) { if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { props[propName] = config[propName]; } } } // Children can be more than one argument, and those are transferred onto // the newly allocated props object. var childrenLength = arguments.length - 2; if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 2]; } props.children = childArray; } // Resolve default props if (type && type.defaultProps) { var defaultProps = type.defaultProps; for (propName in defaultProps) { if (typeof props[propName] === 'undefined') { props[propName] = defaultProps[propName]; } } } return new ReactElement( type, key, ref, ReactCurrentOwner.current, ReactContext.current, props ); }; ReactElement.createFactory = function(type) { var factory = ReactElement.createElement.bind(null, type); // Expose the type on the factory and the prototype so that it can be // easily accessed on elements. E.g. <Foo />.type === Foo.type. // This should not be named `constructor` since this may not be the function // that created the element, and it may not even be a constructor. // Legacy hook TODO: Warn if this is accessed factory.type = type; return factory; }; ReactElement.cloneAndReplaceProps = function(oldElement, newProps) { var newElement = new ReactElement( oldElement.type, oldElement.key, oldElement.ref, oldElement._owner, oldElement._context, newProps ); if ("production" !== process.env.NODE_ENV) { // If the key on the original is valid, then the clone is valid newElement._store.validated = oldElement._store.validated; } return newElement; }; ReactElement.cloneElement = function(element, config, children) { var propName; // Original props are copied var props = assign({}, element.props); // Reserved names are extracted var key = element.key; var ref = element.ref; // Owner will be preserved, unless ref is overridden var owner = element._owner; if (config != null) { if (config.ref !== undefined) { // Silently steal the ref from the parent. ref = config.ref; owner = ReactCurrentOwner.current; } if (config.key !== undefined) { key = '' + config.key; } // Remaining properties override existing props for (propName in config) { if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { props[propName] = config[propName]; } } } // Children can be more than one argument, and those are transferred onto // the newly allocated props object. var childrenLength = arguments.length - 2; if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 2]; } props.children = childArray; } return new ReactElement( element.type, key, ref, owner, element._context, props ); }; /** * @param {?object} object * @return {boolean} True if `object` is a valid component. * @final */ ReactElement.isValidElement = function(object) { // ReactTestUtils is often used outside of beforeEach where as React is // within it. This leads to two different instances of React on the same // page. To identify a element from a different React instance we use // a flag instead of an instanceof check. var isElement = !!(object && object._isReactElement); // if (isElement && !(object instanceof ReactElement)) { // This is an indicator that you're using multiple versions of React at the // same time. This will screw with ownership and stuff. Fix it, please. // TODO: We could possibly warn here. // } return isElement; }; module.exports = ReactElement; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(166))) /***/ }, /* 168 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ReactContext */ 'use strict'; var assign = __webpack_require__(169); var emptyObject = __webpack_require__(170); var warning = __webpack_require__(171); var didWarn = false; /** * Keeps track of the current context. * * The context is automatically passed down the component ownership hierarchy * and is accessible via `this.context` on ReactCompositeComponents. */ var ReactContext = { /** * @internal * @type {object} */ current: emptyObject, /** * Temporarily extends the current context while executing scopedCallback. * * A typical use case might look like * * render: function() { * var children = ReactContext.withContext({foo: 'foo'}, () => ( * * )); * return <div>{children}</div>; * } * * @param {object} newContext New context to merge into the existing context * @param {function} scopedCallback Callback to run with the new context * @return {ReactComponent|array<ReactComponent>} */ withContext: function(newContext, scopedCallback) { if ("production" !== process.env.NODE_ENV) { ("production" !== process.env.NODE_ENV ? warning( didWarn, 'withContext is deprecated and will be removed in a future version. ' + 'Use a wrapper component with getChildContext instead.' ) : null); didWarn = true; } var result; var previousContext = ReactContext.current; ReactContext.current = assign({}, previousContext, newContext); try { result = scopedCallback(); } finally { ReactContext.current = previousContext; } return result; } }; module.exports = ReactContext; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(166))) /***/ }, /* 169 */ /***/ function(module, exports) { /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule Object.assign */ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign 'use strict'; function assign(target, sources) { if (target == null) { throw new TypeError('Object.assign target cannot be null or undefined'); } var to = Object(target); var hasOwnProperty = Object.prototype.hasOwnProperty; for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) { var nextSource = arguments[nextIndex]; if (nextSource == null) { continue; } var from = Object(nextSource); // We don't currently support accessors nor proxies. Therefore this // copy cannot throw. If we ever supported this then we must handle // exceptions and side-effects. We don't support symbols so they won't // be transferred. for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } } return to; } module.exports = assign; /***/ }, /* 170 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule emptyObject */ "use strict"; var emptyObject = {}; if ("production" !== process.env.NODE_ENV) { Object.freeze(emptyObject); } module.exports = emptyObject; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(166))) /***/ }, /* 171 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule warning */ "use strict"; var emptyFunction = __webpack_require__(172); /** * Similar to invariant but only logs a warning if the condition is not met. * This can be used to log issues in development environments in critical * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ var warning = emptyFunction; if ("production" !== process.env.NODE_ENV) { warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]); if (format === undefined) { throw new Error( '`warning(condition, format, ...args)` requires a warning ' + 'message argument' ); } if (format.length < 10 || /^[s\W]*$/.test(format)) { throw new Error( 'The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format ); } if (format.indexOf('Failed Composite propType: ') === 0) { return; // Ignore CompositeComponent proptype check. } if (!condition) { var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];}); console.warn(message); try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch(x) {} } }; } module.exports = warning; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(166))) /***/ }, /* 172 */ /***/ function(module, exports) { /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule emptyFunction */ function makeEmptyFunction(arg) { return function() { return arg; }; } /** * This function accepts and discards inputs; it has no side effects. This is * primarily useful idiomatically for overridable function endpoints which * always need to be callable, since JS lacks a null-call idiom ala Cocoa. */ function emptyFunction() {} emptyFunction.thatReturns = makeEmptyFunction; emptyFunction.thatReturnsFalse = makeEmptyFunction(false); emptyFunction.thatReturnsTrue = makeEmptyFunction(true); emptyFunction.thatReturnsNull = makeEmptyFunction(null); emptyFunction.thatReturnsThis = function() { return this; }; emptyFunction.thatReturnsArgument = function(arg) { return arg; }; module.exports = emptyFunction; /***/ }, /* 173 */ /***/ function(module, exports) { /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ReactCurrentOwner */ 'use strict'; /** * Keeps track of the current owner. * * The current owner is the component who should own any components that are * currently being constructed. * * The depth indicate how many composite components are above this render level. */ var ReactCurrentOwner = { /** * @internal * @type {ReactComponent} */ current: null }; module.exports = ReactCurrentOwner; /***/ }, /* 174 */ /***/ function(module, exports, __webpack_require__) { /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ReactPropTransferer */ 'use strict'; var assign = __webpack_require__(169); var emptyFunction = __webpack_require__(172); var joinClasses = __webpack_require__(175); /** * Creates a transfer strategy that will merge prop values using the supplied * `mergeStrategy`. If a prop was previously unset, this just sets it. * * @param {function} mergeStrategy * @return {function} */ function createTransferStrategy(mergeStrategy) { return function(props, key, value) { if (!props.hasOwnProperty(key)) { props[key] = value; } else { props[key] = mergeStrategy(props[key], value); } }; } var transferStrategyMerge = createTransferStrategy(function(a, b) { // `merge` overrides the first object's (`props[key]` above) keys using the // second object's (`value`) keys. An object's style's existing `propA` would // get overridden. Flip the order here. return assign({}, b, a); }); /** * Transfer strategies dictate how props are transferred by `transferPropsTo`. * NOTE: if you add any more exceptions to this list you should be sure to * update `cloneWithProps()` accordingly. */ var TransferStrategies = { /** * Never transfer `children`. */ children: emptyFunction, /** * Transfer the `className` prop by merging them. */ className: createTransferStrategy(joinClasses), /** * Transfer the `style` prop (which is an object) by merging them. */ style: transferStrategyMerge }; /** * Mutates the first argument by transferring the properties from the second * argument. * * @param {object} props * @param {object} newProps * @return {object} */ function transferInto(props, newProps) { for (var thisKey in newProps) { if (!newProps.hasOwnProperty(thisKey)) { continue; } var transferStrategy = TransferStrategies[thisKey]; if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) { transferStrategy(props, thisKey, newProps[thisKey]); } else if (!props.hasOwnProperty(thisKey)) { props[thisKey] = newProps[thisKey]; } } return props; } /** * ReactPropTransferer are capable of transferring props to another component * using a `transferPropsTo` method. * * @class ReactPropTransferer */ var ReactPropTransferer = { /** * Merge two props objects using TransferStrategies. * * @param {object} oldProps original props (they take precedence) * @param {object} newProps new props to merge in * @return {object} a new object containing both sets of props merged. */ mergeProps: function(oldProps, newProps) { return transferInto(assign({}, oldProps), newProps); } }; module.exports = ReactPropTransferer; /***/ }, /* 175 */ /***/ function(module, exports) { /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule joinClasses * @typechecks static-only */ 'use strict'; /** * Combines multiple className strings into one. * http://jsperf.com/joinclasses-args-vs-array * * @param {...?string} classes * @return {string} */ function joinClasses(className/*, ... */) { if (!className) { className = ''; } var nextClass; var argLength = arguments.length; if (argLength > 1) { for (var ii = 1; ii < argLength; ii++) { nextClass = arguments[ii]; if (nextClass) { className = (className ? className + ' ' : '') + nextClass; } } } return className; } module.exports = joinClasses; /***/ }, /* 176 */ /***/ function(module, exports) { /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule keyOf */ /** * Allows extraction of a minified key. Let's the build system minify keys * without loosing the ability to dynamically use key strings as values * themselves. Pass in an object with a single key/val pair and it will return * you the string key of that single record. Suppose you want to grab the * value for a key 'className' inside of an object. Key/val minification may * have aliased that key to be 'xa12'. keyOf({className: null}) will return * 'xa12' in that case. Resolve keys you want to use once at startup time, then * reuse those resolutions. */ var keyOf = function(oneKeyObj) { var key; for (key in oneKeyObj) { if (!oneKeyObj.hasOwnProperty(key)) { continue; } return key; } return null; }; module.exports = keyOf; /***/ }, /* 177 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _classnames = __webpack_require__(163); var _classnames2 = _interopRequireDefault(_classnames); var getDotCount = function getDotCount(spec) { var dots; dots = Math.ceil(spec.slideCount / spec.slidesToScroll); return dots; }; var Dots = _react2['default'].createClass({ displayName: 'Dots', clickHandler: function clickHandler(options, e) { // In Autoplay the focus stays on clicked button even after transition // to next slide. That only goes away by click somewhere outside e.preventDefault(); this.props.clickHandler(options); }, render: function render() { var _this = this; var dotCount = getDotCount({ slideCount: this.props.slideCount, slidesToScroll: this.props.slidesToScroll }); // Apply join & split to Array to pre-fill it for IE8 // // Credit: http://stackoverflow.com/a/13735425/1849458 var dots = Array.apply(null, Array(dotCount + 1).join('0').split('')).map(function (x, i) { var className = (0, _classnames2['default'])({ 'slick-active': _this.props.currentSlide === i * _this.props.slidesToScroll }); var dotOptions = { message: 'dots', index: i, slidesToScroll: _this.props.slidesToScroll, currentSlide: _this.props.currentSlide }; return _react2['default'].createElement( 'li', { key: i, className: className }, _react2['default'].createElement( 'button', { onClick: _this.clickHandler.bind(_this, dotOptions) }, i ) ); }); return _react2['default'].createElement( 'ul', { className: this.props.dotsClass, style: { display: 'block' } }, dots ); } }); exports.Dots = Dots; /***/ }, /* 178 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _classnames = __webpack_require__(163); var _classnames2 = _interopRequireDefault(_classnames); var PrevArrow = _react2['default'].createClass({ displayName: 'PrevArrow', clickHandler: function clickHandler(options, e) { e.preventDefault(); this.props.clickHandler(options, e); }, render: function render() { var prevClasses = { 'slick-prev': true }; var prevHandler = this.clickHandler.bind(this, { message: 'previous' }); if (!this.props.infinite && (this.props.currentSlide === 0 || this.props.slideCount <= this.props.slidesToShow)) { prevClasses['slick-disabled'] = true; prevHandler = null; } var prevArrowProps = { key: '0', ref: 'previous', 'data-role': 'none', className: (0, _classnames2['default'])(prevClasses), style: { display: 'block' }, onClick: prevHandler }; var prevArrow; if (this.props.prevArrow) { prevArrow = _react2['default'].createElement(this.props.prevArrow, prevArrowProps); } else { prevArrow = _react2['default'].createElement( 'button', _extends({ key: '0', type: 'button' }, prevArrowProps), ' Previous' ); } return prevArrow; } }); exports.PrevArrow = PrevArrow; var NextArrow = _react2['default'].createClass({ displayName: 'NextArrow', clickHandler: function clickHandler(options, e) { e.preventDefault(); this.props.clickHandler(options, e); }, render: function render() { var nextClasses = { 'slick-next': true }; var nextHandler = this.clickHandler.bind(this, { message: 'next' }); if (!this.props.infinite) { if (this.props.centerMode && this.props.currentSlide >= this.props.slideCount - 1) { nextClasses['slick-disabled'] = true; nextHandler = null; } else { if (this.props.currentSlide >= this.props.slideCount - this.props.slidesToShow) { nextClasses['slick-disabled'] = true; nextHandler = null; } } if (this.props.slideCount <= this.props.slidesToShow) { nextClasses['slick-disabled'] = true; nextHandler = null; } } var nextArrowProps = { key: '1', ref: 'next', 'data-role': 'none', className: (0, _classnames2['default'])(nextClasses), style: { display: 'block' }, onClick: nextHandler }; var nextArrow; if (this.props.nextArrow) { nextArrow = _react2['default'].createElement(this.props.nextArrow, nextArrowProps); } else { nextArrow = _react2['default'].createElement( 'button', _extends({ key: '1', type: 'button' }, nextArrowProps), ' Next' ); } return nextArrow; } }); exports.NextArrow = NextArrow; /***/ }, /* 179 */ /***/ function(module, exports, __webpack_require__) { var camel2hyphen = __webpack_require__(180); var isDimension = function (feature) { var re = /[height|width]$/; return re.test(feature); }; var obj2mq = function (obj) { var mq = ''; var features = Object.keys(obj); features.forEach(function (feature, index) { var value = obj[feature]; feature = camel2hyphen(feature); // Add px to dimension features if (isDimension(feature) && typeof value === 'number') { value = value + 'px'; } if (value === true) { mq += feature; } else if (value === false) { mq += 'not ' + feature; } else { mq += '(' + feature + ': ' + value + ')'; } if (index < features.length-1) { mq += ' and ' } }); return mq; }; var json2mq = function (query) { var mq = ''; if (typeof query === 'string') { return query; } // Handling array of media queries if (query instanceof Array) { query.forEach(function (q, index) { mq += obj2mq(q); if (index < query.length-1) { mq += ', ' } }); return mq; } // Handling single media query return obj2mq(query); }; module.exports = json2mq; /***/ }, /* 180 */ /***/ function(module, exports) { var camel2hyphen = function (str) { return str .replace(/[A-Z]/g, function (match) { return '-' + match.toLowerCase(); }) .toLowerCase(); }; module.exports = camel2hyphen; /***/ }, /* 181 */ /***/ function(module, exports, __webpack_require__) { var canUseDOM = __webpack_require__(182); var enquire = canUseDOM && __webpack_require__(183); var json2mq = __webpack_require__(179); var ResponsiveMixin = { media: function (query, handler) { query = json2mq(query); if (typeof handler === 'function') { handler = { match: handler }; } enquire.register(query, handler); // Queue the handlers to unregister them at unmount if (! this._responsiveMediaHandlers) { this._responsiveMediaHandlers = []; } this._responsiveMediaHandlers.push({query: query, handler: handler}); }, componentWillUnmount: function () { if (this._responsiveMediaHandlers) { this._responsiveMediaHandlers.forEach(function(obj) { enquire.unregister(obj.query, obj.handler); }); } } }; module.exports = ResponsiveMixin; /***/ }, /* 182 */ /***/ function(module, exports) { var canUseDOM = !!( typeof window !== 'undefined' && window.document && window.document.createElement ); module.exports = canUseDOM; /***/ }, /* 183 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/*! * enquire.js v2.1.1 - Awesome Media Queries in JavaScript * Copyright (c) 2014 Nick Williams - http://wicky.nillia.ms/enquire.js * License: MIT (http://www.opensource.org/licenses/mit-license.php) */ ;(function (name, context, factory) { var matchMedia = window.matchMedia; if (typeof module !== 'undefined' && module.exports) { module.exports = factory(matchMedia); } else if (true) { !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { return (context[name] = factory(matchMedia)); }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else { context[name] = factory(matchMedia); } }('enquire', this, function (matchMedia) { 'use strict'; /*jshint unused:false */ /** * Helper function for iterating over a collection * * @param collection * @param fn */ function each(collection, fn) { var i = 0, length = collection.length, cont; for(i; i < length; i++) { cont = fn(collection[i], i); if(cont === false) { break; //allow early exit } } } /** * Helper function for determining whether target object is an array * * @param target the object under test * @return {Boolean} true if array, false otherwise */ function isArray(target) { return Object.prototype.toString.apply(target) === '[object Array]'; } /** * Helper function for determining whether target object is a function * * @param target the object under test * @return {Boolean} true if function, false otherwise */ function isFunction(target) { return typeof target === 'function'; } /** * Delegate to handle a media query being matched and unmatched. * * @param {object} options * @param {function} options.match callback for when the media query is matched * @param {function} [options.unmatch] callback for when the media query is unmatched * @param {function} [options.setup] one-time callback triggered the first time a query is matched * @param {boolean} [options.deferSetup=false] should the setup callback be run immediately, rather than first time query is matched? * @constructor */ function QueryHandler(options) { this.options = options; !options.deferSetup && this.setup(); } QueryHandler.prototype = { /** * coordinates setup of the handler * * @function */ setup : function() { if(this.options.setup) { this.options.setup(); } this.initialised = true; }, /** * coordinates setup and triggering of the handler * * @function */ on : function() { !this.initialised && this.setup(); this.options.match && this.options.match(); }, /** * coordinates the unmatch event for the handler * * @function */ off : function() { this.options.unmatch && this.options.unmatch(); }, /** * called when a handler is to be destroyed. * delegates to the destroy or unmatch callbacks, depending on availability. * * @function */ destroy : function() { this.options.destroy ? this.options.destroy() : this.off(); }, /** * determines equality by reference. * if object is supplied compare options, if function, compare match callback * * @function * @param {object || function} [target] the target for comparison */ equals : function(target) { return this.options === target || this.options.match === target; } }; /** * Represents a single media query, manages it's state and registered handlers for this query * * @constructor * @param {string} query the media query string * @param {boolean} [isUnconditional=false] whether the media query should run regardless of whether the conditions are met. Primarily for helping older browsers deal with mobile-first design */ function MediaQuery(query, isUnconditional) { this.query = query; this.isUnconditional = isUnconditional; this.handlers = []; this.mql = matchMedia(query); var self = this; this.listener = function(mql) { self.mql = mql; self.assess(); }; this.mql.addListener(this.listener); } MediaQuery.prototype = { /** * add a handler for this query, triggering if already active * * @param {object} handler * @param {function} handler.match callback for when query is activated * @param {function} [handler.unmatch] callback for when query is deactivated * @param {function} [handler.setup] callback for immediate execution when a query handler is registered * @param {boolean} [handler.deferSetup=false] should the setup callback be deferred until the first time the handler is matched? */ addHandler : function(handler) { var qh = new QueryHandler(handler); this.handlers.push(qh); this.matches() && qh.on(); }, /** * removes the given handler from the collection, and calls it's destroy methods * * @param {object || function} handler the handler to remove */ removeHandler : function(handler) { var handlers = this.handlers; each(handlers, function(h, i) { if(h.equals(handler)) { h.destroy(); return !handlers.splice(i,1); //remove from array and exit each early } }); }, /** * Determine whether the media query should be considered a match * * @return {Boolean} true if media query can be considered a match, false otherwise */ matches : function() { return this.mql.matches || this.isUnconditional; }, /** * Clears all handlers and unbinds events */ clear : function() { each(this.handlers, function(handler) { handler.destroy(); }); this.mql.removeListener(this.listener); this.handlers.length = 0; //clear array }, /* * Assesses the query, turning on all handlers if it matches, turning them off if it doesn't match */ assess : function() { var action = this.matches() ? 'on' : 'off'; each(this.handlers, function(handler) { handler[action](); }); } }; /** * Allows for registration of query handlers. * Manages the query handler's state and is responsible for wiring up browser events * * @constructor */ function MediaQueryDispatch () { if(!matchMedia) { throw new Error('matchMedia not present, legacy browsers require a polyfill'); } this.queries = {}; this.browserIsIncapable = !matchMedia('only all').matches; } MediaQueryDispatch.prototype = { /** * Registers a handler for the given media query * * @param {string} q the media query * @param {object || Array || Function} options either a single query handler object, a function, or an array of query handlers * @param {function} options.match fired when query matched * @param {function} [options.unmatch] fired when a query is no longer matched * @param {function} [options.setup] fired when handler first triggered * @param {boolean} [options.deferSetup=false] whether setup should be run immediately or deferred until query is first matched * @param {boolean} [shouldDegrade=false] whether this particular media query should always run on incapable browsers */ register : function(q, options, shouldDegrade) { var queries = this.queries, isUnconditional = shouldDegrade && this.browserIsIncapable; if(!queries[q]) { queries[q] = new MediaQuery(q, isUnconditional); } //normalise to object in an array if(isFunction(options)) { options = { match : options }; } if(!isArray(options)) { options = [options]; } each(options, function(handler) { queries[q].addHandler(handler); }); return this; }, /** * unregisters a query and all it's handlers, or a specific handler for a query * * @param {string} q the media query to target * @param {object || function} [handler] specific handler to unregister */ unregister : function(q, handler) { var query = this.queries[q]; if(query) { if(handler) { query.removeHandler(handler); } else { query.clear(); delete this.queries[q]; } } return this; } }; return new MediaQueryDispatch(); })); /***/ }, /* 184 */ /***/ function(module, exports) { /* eslint-disable no-unused-vars */ 'use strict'; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function toObject(val) { if (val === null || val === undefined) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } module.exports = Object.assign || function (target, source) { var from; var to = toObject(target); var symbols; for (var s = 1; s < arguments.length; s++) { from = Object(arguments[s]); for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } if (Object.getOwnPropertySymbols) { symbols = Object.getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from, symbols[i])) { to[symbols[i]] = from[symbols[i]]; } } } } return to; }; /***/ }, /* 185 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _rcTabs = __webpack_require__(186); var _rcTabs2 = _interopRequireDefault(_rcTabs); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var prefixCls = 'ant-tabs'; var AntTabs = (function (_React$Component) { _inherits(AntTabs, _React$Component); function AntTabs() { _classCallCheck(this, AntTabs); _get(Object.getPrototypeOf(AntTabs.prototype), 'constructor', this).apply(this, arguments); } _createClass(AntTabs, [{ key: 'render', value: function render() { var sizeCls = ''; if (this.props.size === 'mini') { sizeCls = prefixCls + '-mini'; } return _react2['default'].createElement(_rcTabs2['default'], _extends({}, this.props, { className: sizeCls })); } }]); return AntTabs; })(_react2['default'].Component); AntTabs.defaultProps = { prefixCls: prefixCls, size: 'normal' }; AntTabs.TabPane = _rcTabs2['default'].TabPane; exports['default'] = AntTabs; module.exports = exports['default']; /***/ }, /* 186 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(187); /***/ }, /* 187 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _KeyCode = __webpack_require__(188); var _KeyCode2 = _interopRequireDefault(_KeyCode); var _TabPane = __webpack_require__(189); var _TabPane2 = _interopRequireDefault(_TabPane); var _Nav = __webpack_require__(190); var _Nav2 = _interopRequireDefault(_Nav); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); function noop() {} var Tabs = _react2['default'].createClass({ displayName: 'Tabs', propTypes: { onTabClick: _react2['default'].PropTypes.func, onChange: _react2['default'].PropTypes.func, children: _react2['default'].PropTypes.any, animation: _react2['default'].PropTypes.string }, getInitialState: function getInitialState() { var props = this.props; var activeKey = undefined; if ('activeKey' in props) { activeKey = props.activeKey; } else if ('defaultActiveKey' in props) { activeKey = props.defaultActiveKey; } else { _react2['default'].Children.forEach(props.children, function (child) { if (!activeKey && !child.props.disabled) { activeKey = child.key; } }); } // cache panels this.renderPanels = {}; return { activeKey: activeKey }; }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-tabs', onChange: noop, tabPosition: 'top', style: {}, contentStyle: {}, navStyle: {}, onTabClick: noop }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('activeKey' in nextProps) { this.setActiveKey(nextProps.activeKey); } }, onTabDestroy: function onTabDestroy(key) { delete this.renderPanels[key]; }, onTabClick: function onTabClick(key) { this.props.onTabClick(key); if (this.state.activeKey !== key) { this.setActiveKey(key); this.props.onChange(key); } }, onKeyDown: function onKeyDown(e) { if (e.target !== _react2['default'].findDOMNode(this)) { return; } var eventKeyCode = e.keyCode; switch (eventKeyCode) { case _KeyCode2['default'].RIGHT: case _KeyCode2['default'].DOWN: e.preventDefault(); var nextKey = this.getNextActiveKey(true); this.onTabClick(nextKey); break; case _KeyCode2['default'].LEFT: case _KeyCode2['default'].UP: e.preventDefault(); var previousKey = this.getNextActiveKey(false); this.onTabClick(previousKey); break; default: } }, getNextActiveKey: function getNextActiveKey(next) { var activeKey = this.state.activeKey; var children = []; _react2['default'].Children.forEach(this.props.children, function (c) { if (!c.props.disabled) { if (next) { children.push(c); } else { children.unshift(c); } } }); var length = children.length; var ret = length && children[0].key; children.forEach(function (child, i) { if (child.key === activeKey) { if (i === length - 1) { ret = children[0].key; } else { ret = children[i + 1].key; } } }); return ret; }, getTabPanes: function getTabPanes() { var _this = this; var state = this.state; var props = this.props; var activeKey = state.activeKey; var children = props.children; var newChildren = []; var renderPanels = this.renderPanels; _react2['default'].Children.forEach(children, function (c) { var child = c; var key = child.key; var active = activeKey === key; if (active || renderPanels[key]) { child = active ? child : renderPanels[key]; renderPanels[key] = _react2['default'].cloneElement(child, { active: active, onDestroy: _this.onTabDestroy.bind(_this, key), // eventKey: key, rootPrefixCls: props.prefixCls }); newChildren.push(renderPanels[key]); } else { // do not change owner ... // or else will destroy and reinit // newChildren.push(<TabPane active={false} // key={key} // eventKey={key} // rootPrefixCls={this.props.prefixCls}></TabPane>); // return // lazy load newChildren.push(_react2['default'].cloneElement(child, { active: false, // eventKey: key, rootPrefixCls: props.prefixCls }, [])); } }); return newChildren; }, render: function render() { var props = this.props; var prefixCls = props.prefixCls; var tabPosition = props.tabPosition; var cls = prefixCls + ' ' + prefixCls + '-' + tabPosition; var tabMovingDirection = this.state.tabMovingDirection; if (props.className) { cls += ' ' + props.className; } var animation = this.props.animation; var tabPanes = this.getTabPanes(); var transitionName = undefined; transitionName = props.transitionName && props.transitionName[tabMovingDirection || 'backward']; if (!transitionName && animation) { transitionName = prefixCls + '-' + animation + '-' + (tabMovingDirection || 'backward'); } if (transitionName) { tabPanes = _react2['default'].createElement( _rcAnimate2['default'], { showProp: 'active', exclusive: true, transitionName: transitionName }, tabPanes ); } var contents = [_react2['default'].createElement(_Nav2['default'], { prefixCls: prefixCls, key: 'nav', tabPosition: tabPosition, style: props.navStyle, onTabClick: this.onTabClick, tabMovingDirection: tabMovingDirection, panels: this.props.children, activeKey: this.state.activeKey }), _react2['default'].createElement( 'div', { className: prefixCls + '-content', style: props.contentStyle, key: 'content' }, tabPanes )]; if (tabPosition === 'bottom') { contents.reverse(); } return _react2['default'].createElement( 'div', { className: cls, tabIndex: '0', style: props.style, onKeyDown: this.onKeyDown }, contents ); }, setActiveKey: function setActiveKey(activeKey) { var _this2 = this; var currentActiveKey = this.state.activeKey; if (!currentActiveKey) { this.setState({ activeKey: activeKey }); } else { (function () { var keys = []; _react2['default'].Children.forEach(_this2.props.children, function (c) { keys.push(c.key); }); var tabMovingDirection = keys.indexOf(currentActiveKey) > keys.indexOf(activeKey) ? 'backward' : 'forward'; _this2.setState({ activeKey: activeKey, tabMovingDirection: tabMovingDirection }); })(); } } }); Tabs.TabPane = _TabPane2['default']; exports['default'] = Tabs; module.exports = exports['default']; /***/ }, /* 188 */ /***/ function(module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = { /** * LEFT */ LEFT: 37, // also NUM_WEST /** * UP */ UP: 38, // also NUM_NORTH /** * RIGHT */ RIGHT: 39, // also NUM_EAST /** * DOWN */ DOWN: 40 }; module.exports = exports["default"]; // also NUM_SOUTH /***/ }, /* 189 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var TabPane = _react2['default'].createClass({ displayName: 'TabPane', propTypes: { onDestroy: _react2['default'].PropTypes.func }, componentWillUnmount: function componentWillUnmount() { if (this.props.onDestroy) { this.props.onDestroy(); } }, render: function render() { var props = this.props; var prefixCls = props.rootPrefixCls + '-tabpane'; var cls = props.active ? '' : prefixCls + '-hidden'; cls += ' ' + prefixCls; return _react2['default'].createElement( 'div', { className: cls }, props.children ); } }); exports['default'] = TabPane; module.exports = exports['default']; /***/ }, /* 190 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _utils = __webpack_require__(191); function noop() {} var Nav = _react2['default'].createClass({ displayName: 'Nav', propTypes: { tabPosition: _react2['default'].PropTypes.string, onTabClick: _react2['default'].PropTypes.func }, mixins: [__webpack_require__(192)], getInitialState: function getInitialState() { return { next: false, offset: 0, prev: false }; }, componentDidMount: function componentDidMount() { this.componentDidUpdate(); }, componentDidUpdate: function componentDidUpdate(prevProps) { if (prevProps && prevProps.tabPosition !== this.props.tabPosition) { this.setOffset(0); return; } var navNode = _react2['default'].findDOMNode(this.refs.nav); var navNodeWH = this.getOffsetWH(navNode); var navWrapNode = _react2['default'].findDOMNode(this.refs.navWrap); var navWrapNodeWH = this.getOffsetWH(navWrapNode); var state = this.state; var offset = state.offset; if (navWrapNodeWH - offset < navNodeWH) { if (!state.next) { this.setNext(true); } } else { var minOffset = navWrapNodeWH - navNodeWH; if (minOffset < 0 && minOffset > offset) { if (state.next) { this.setNext(false); } this.setOffset(minOffset); offset = minOffset; } } if (offset < 0) { if (!state.prev) { this.setPrev(true); } } else if (state.prev) { this.setPrev(false); } }, onTabClick: function onTabClick(key) { this.props.onTabClick(key); }, getTabs: function getTabs() { var _this = this; var props = this.props; var children = props.panels; var activeKey = props.activeKey; var rst = []; var prefixCls = props.prefixCls; _react2['default'].Children.forEach(children, function (child) { var key = child.key; var cls = activeKey === key ? prefixCls + '-tab-active' : ''; cls += ' ' + prefixCls + '-tab'; var events = {}; if (child.props.disabled) { cls += ' ' + prefixCls + '-tab-disabled'; } else { events = { onClick: _this.onTabClick.bind(_this, key) }; } var ref = {}; if (activeKey === key) { ref.ref = 'activeTab'; } rst.push(_react2['default'].createElement( 'div', _extends({}, events, { className: cls, key: key }, ref), _react2['default'].createElement( 'a', null, child.props.tab ) )); }); return rst; }, getOffsetWH: function getOffsetWH(node) { var tabPosition = this.props.tabPosition; var prop = 'offsetWidth'; if (tabPosition === 'left' || tabPosition === 'right') { prop = 'offsetHeight'; } return node[prop]; }, render: function render() { var props = this.props; var state = this.state; var prefixCls = props.prefixCls; var tabs = this.getTabs(); var tabMovingDirection = props.tabMovingDirection; var tabPosition = props.tabPosition; var inkBarClass = prefixCls + '-ink-bar'; if (tabMovingDirection) { inkBarClass += ' ' + prefixCls + '-ink-bar-transition-' + tabMovingDirection; } var nextButton = undefined; var prevButton = undefined; var showNextPrev = state.prev || state.next; if (showNextPrev) { var _cx, _cx2; prevButton = _react2['default'].createElement( 'span', { onClick: state.prev ? this.prev : noop, unselectable: 'unselectable', className: (0, _utils.cx)((_cx = {}, _defineProperty(_cx, prefixCls + '-tab-prev', 1), _defineProperty(_cx, prefixCls + '-tab-btn-disabled', !state.prev), _cx)) }, _react2['default'].createElement('span', { className: prefixCls + '-tab-prev-icon' }) ); nextButton = _react2['default'].createElement( 'span', { onClick: state.next ? this.next : noop, unselectable: 'unselectable', className: (0, _utils.cx)((_cx2 = {}, _defineProperty(_cx2, prefixCls + '-tab-next', 1), _defineProperty(_cx2, prefixCls + '-tab-btn-disabled', !state.next), _cx2)) }, _react2['default'].createElement('span', { className: prefixCls + '-tab-next-icon' }) ); } var navOffset = {}; if (tabPosition === 'left' || tabPosition === 'right') { navOffset = { top: state.offset }; } else { navOffset = { left: state.offset }; } return _react2['default'].createElement( 'div', { className: prefixCls + '-nav-container ' + (showNextPrev ? prefixCls + '-nav-container-scrolling' : ''), style: props.style, ref: 'container' }, prevButton, nextButton, _react2['default'].createElement( 'div', { className: prefixCls + '-nav-wrap', ref: 'navWrap' }, _react2['default'].createElement( 'div', { className: prefixCls + '-nav-scroll' }, _react2['default'].createElement( 'div', { className: prefixCls + '-nav', ref: 'nav', style: navOffset }, _react2['default'].createElement('div', { className: inkBarClass, ref: 'inkBar' }), tabs ) ) ) ); }, setOffset: function setOffset(offset) { this.setState({ offset: Math.min(0, offset) }); }, prev: function prev() { var navWrapNode = _react2['default'].findDOMNode(this.refs.navWrap); var navWrapNodeWH = this.getOffsetWH(navWrapNode); var state = this.state; var offset = state.offset; this.setOffset(offset + navWrapNodeWH); }, next: function next() { var navWrapNode = _react2['default'].findDOMNode(this.refs.navWrap); var navWrapNodeWH = this.getOffsetWH(navWrapNode); var state = this.state; var offset = state.offset; this.setOffset(offset - navWrapNodeWH); }, setPrev: function setPrev(v) { this.setState({ prev: v }); }, setNext: function setNext(v) { this.setState({ next: v }); } }); exports['default'] = Nav; module.exports = exports['default']; /***/ }, /* 191 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; // ie6,7,8 standard mode ret = d.documentElement[method]; if (typeof ret !== 'number') { // quirks mode ret = d.body[method]; } } return ret; } function offset(elem) { var box = undefined; var x = undefined; var y = undefined; var doc = elem.ownerDocument; var body = doc.body; var docElem = doc && doc.documentElement; box = elem.getBoundingClientRect(); x = box.left; y = box.top; x -= docElem.clientLeft || body.clientLeft || 0; y -= docElem.clientTop || body.clientTop || 0; var w = doc.defaultView || doc.parentWindow; x += getScroll(w); y += getScroll(w, true); return { left: x, top: y }; } exports['default'] = { getScroll: getScroll, offset: offset, cx: function cx(v) { var ret = []; for (var k in v) { if (v[k]) { ret.push(k); } } return ret.join(' '); } }; module.exports = exports['default']; /***/ }, /* 192 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(191); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); function _componentDidUpdate(component) { var refs = component.refs; var containerNode = _react2['default'].findDOMNode(refs.nav); var containerOffset = (0, _utils.offset)(containerNode); var inkBarNode = _react2['default'].findDOMNode(refs.inkBar); var activeTab = refs.activeTab; var tabPosition = component.props.tabPosition; if (activeTab) { var tabNode = _react2['default'].findDOMNode(activeTab); var tabOffset = (0, _utils.offset)(tabNode); if (tabPosition === 'top' || tabPosition === 'bottom') { var left = tabOffset.left - containerOffset.left; inkBarNode.style.left = left + 'px'; inkBarNode.style.top = ''; inkBarNode.style.bottom = ''; inkBarNode.style.right = containerNode.offsetWidth - left - tabNode.offsetWidth + 'px'; } else { var _top = tabOffset.top - containerOffset.top; inkBarNode.style.left = ''; inkBarNode.style.right = ''; inkBarNode.style.top = _top + 'px'; inkBarNode.style.bottom = containerNode.offsetHeight - _top - tabNode.offsetHeight + 'px'; } } inkBarNode.style.display = activeTab ? 'block' : 'none'; } exports['default'] = { componentDidUpdate: function componentDidUpdate() { _componentDidUpdate(this); }, componentDidMount: function componentDidMount() { _componentDidUpdate(this); } }; module.exports = exports['default']; /***/ }, /* 193 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcDialog = __webpack_require__(194); var _rcDialog2 = _interopRequireDefault(_rcDialog); var _rcUtil = __webpack_require__(77); var _confirm = __webpack_require__(208); var _confirm2 = _interopRequireDefault(_confirm); function noop() {} var mousePosition = undefined; var mousePositionEventBinded = undefined; var AntModal = _react2['default'].createClass({ displayName: 'AntModal', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-modal', onOk: noop, onCancel: noop, width: 520, transitionName: 'zoom', maskAnimation: 'fade' }; }, getInitialState: function getInitialState() { return { confirmLoading: false, visible: this.props.visible }; }, handleCancel: function handleCancel() { this.props.onCancel(); }, handleOk: function handleOk() { this.setState({ confirmLoading: true }); this.props.onOk(); }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var newState = {}; if ('visible' in nextProps) { newState.visible = nextProps.visible; // 隐藏后默认去除按钮 loading 效果 if (!nextProps.visible) { newState.confirmLoading = false; } } if ('confirmLoading' in nextProps) { newState.confirmLoading = nextProps.confirmLoading; } this.setState(newState); }, componentDidMount: function componentDidMount() { if (mousePositionEventBinded) { return; } // 只有点击事件支持从鼠标位置动画展开 _rcUtil.Dom.addEventListener(document.body, 'click', function onDocumentMousemove(e) { mousePosition = { x: e.pageX, y: e.pageY }; // 20ms 内发生过点击事件,则从点击位置动画展示 // 否则直接 zoom 展示 // 这样可以兼容非点击方式展开 setTimeout(function () { return mousePosition = null; }, 20); }); mousePositionEventBinded = true; }, render: function render() { var loadingClass = this.state.confirmLoading ? ' ant-btn-loading' : ''; var props = this.props; var defaultFooter = [_react2['default'].createElement( 'button', { key: 'cancel', type: 'button', className: 'ant-btn ant-btn-lg', onClick: this.handleCancel }, '取 消' ), _react2['default'].createElement( 'button', { key: 'confirm', type: 'button', className: 'ant-btn ant-btn-primary ant-btn-lg' + loadingClass, onClick: this.handleOk }, '确 定' )]; var footer = props.footer || defaultFooter; var visible = this.state.visible; return _react2['default'].createElement(_rcDialog2['default'], _extends({ onClose: this.handleCancel, footer: footer }, props, { visible: visible, mousePosition: mousePosition })); } }); AntModal.info = function (props) { props.iconClassName = 'anticon-info-circle'; props.okCancel = false; return (0, _confirm2['default'])(props); }; AntModal.success = function (props) { props.iconClassName = 'anticon-check-circle'; props.okCancel = false; return (0, _confirm2['default'])(props); }; AntModal.error = function (props) { props.iconClassName = 'anticon-exclamation-circle'; props.okCancel = false; return (0, _confirm2['default'])(props); }; AntModal.confirm = function (props) { props.okCancel = true; return (0, _confirm2['default'])(props); }; exports['default'] = AntModal; module.exports = exports['default']; /***/ }, /* 194 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(195); /***/ }, /* 195 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _Dialog = __webpack_require__(196); var _Dialog2 = _interopRequireDefault(_Dialog); var _objectAssign = __webpack_require__(207); var _objectAssign2 = _interopRequireDefault(_objectAssign); function noop() {} function copy(obj, fields) { var ret = {}; fields.forEach(function (f) { if (obj[f] !== undefined) { ret[f] = obj[f]; } }); return ret; } var DialogWrap = (function (_React$Component) { _inherits(DialogWrap, _React$Component); function DialogWrap(props) { var _this = this; _classCallCheck(this, DialogWrap); _get(Object.getPrototypeOf(DialogWrap.prototype), 'constructor', this).call(this, props); this.state = { visible: props.visible }; ['onClose', 'cleanDialogContainer'].forEach(function (m) { _this[m] = _this[m].bind(_this); }); } _createClass(DialogWrap, [{ key: 'componentDidMount', value: function componentDidMount() { this.componentDidUpdate(); } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(props) { if ('visible' in props) { this.setState({ visible: props.visible }); } } }, { key: 'shouldComponentUpdate', value: function shouldComponentUpdate(nextProps, nextState) { return !!(this.state.visible || nextState.visible); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { if (this.dialogRendered) { _react2['default'].render(this.getDialogElement(), this.getDialogContainer()); } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { if (this.dialogContainer) { if (this.state.visible) { _react2['default'].render(this.getDialogElement({ onAfterClose: this.cleanDialogContainer, onClose: noop, visible: false }), this.dialogContainer); } else { this.cleanDialogContainer(); } } } }, { key: 'onClose', value: function onClose() { this.props.onClose(); } }, { key: 'getDialogContainer', value: function getDialogContainer() { if (!this.dialogContainer) { this.dialogContainer = document.createElement('div'); this.dialogContainer.className = this.props.prefixCls + '-container'; document.body.appendChild(this.dialogContainer); } return this.dialogContainer; } }, { key: 'getDialogElement', value: function getDialogElement(extra) { var props = this.props; var dialogProps = copy(props, ['className', 'closable', 'align', 'title', 'footer', 'mask', 'animation', 'transitionName', 'maskAnimation', 'maskTransitionName', 'mousePosition', 'prefixCls', 'style', 'width', 'height', 'zIndex']); (0, _objectAssign2['default'])(dialogProps, { onClose: this.onClose, visible: this.state.visible }, extra); return _react2['default'].createElement( _Dialog2['default'], _extends({}, dialogProps, { key: 'dialog' }), props.children ); } }, { key: 'render', value: function render() { this.dialogRendered = this.dialogRendered || this.state.visible; return null; } }, { key: 'cleanDialogContainer', value: function cleanDialogContainer() { _react2['default'].unmountComponentAtNode(this.getDialogContainer()); document.body.removeChild(this.dialogContainer); this.dialogContainer = null; } }]); return DialogWrap; })(_react2['default'].Component); DialogWrap.defaultProps = { className: '', align: { points: ['tc', 'tc'], offset: [0, 100] }, mask: true, closable: true, prefixCls: 'rc-dialog', onClose: noop }; DialogWrap.propTypes = { className: _react2['default'].PropTypes.string, align: _react2['default'].PropTypes.shape({ align: _react2['default'].PropTypes.array, offset: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.number) }), mask: _react2['default'].PropTypes.bool, closable: _react2['default'].PropTypes.bool, prefixCls: _react2['default'].PropTypes.string, visible: _react2['default'].PropTypes.bool, onClose: _react2['default'].PropTypes.func }; exports['default'] = DialogWrap; module.exports = exports['default']; /***/ }, /* 196 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcAlign = __webpack_require__(197); var _rcAlign2 = _interopRequireDefault(_rcAlign); var _rcUtil = __webpack_require__(77); var _objectAssign = __webpack_require__(207); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); function noop() {} function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; ret = d.documentElement[method]; if (typeof ret !== 'number') { ret = d.body[method]; } } return ret; } function setTransformOrigin(node, value) { var style = node.style; ['Webkit', 'Moz', 'Ms', 'ms'].forEach(function (prefix) { style[prefix + 'TransformOrigin'] = value; }); style['transformOrigin'] = value; } function offset(el) { var rect = el.getBoundingClientRect(); var pos = { left: rect.left, top: rect.top }; var doc = el.ownerDocument; var w = doc.defaultView || doc.parentWindow; pos.left += getScroll(w); pos.top += getScroll(w, 1); return pos; } var Dialog = _react2['default'].createClass({ displayName: 'Dialog', propTypes: { onAfterClose: _react2['default'].PropTypes.func, onClose: _react2['default'].PropTypes.func, closable: _react2['default'].PropTypes.bool, visible: _react2['default'].PropTypes.bool, mousePosition: _react2['default'].PropTypes.object }, getDefaultProps: function getDefaultProps() { return { onAfterClose: noop, onClose: noop }; }, componentDidMount: function componentDidMount() { this.componentDidUpdate({}); }, componentDidUpdate: function componentDidUpdate(prevProps) { var props = this.props; if (props.visible) { // first show if (!prevProps.visible) { this.lastOutSideFocusNode = document.activeElement; (0, _react.findDOMNode)(this.refs.dialog).focus(); } } else if (prevProps.visible) { if (props.mask && this.lastOutSideFocusNode) { try { this.lastOutSideFocusNode.focus(); } catch (e) { this.lastOutSideFocusNode = null; } this.lastOutSideFocusNode = null; } } }, onAnimateLeave: function onAnimateLeave() { this.props.onAfterClose(); }, onMaskClick: function onMaskClick() { if (this.props.closable) { this.close(); } (0, _react.findDOMNode)(this.refs.dialog).focus(); }, onKeyDown: function onKeyDown(e) { var props = this.props; if (props.closable) { if (e.keyCode === _rcUtil.KeyCode.ESC) { this.close(); } } // keep focus inside dialog if (props.visible) { if (e.keyCode === _rcUtil.KeyCode.TAB) { var activeElement = document.activeElement; var dialogRoot = (0, _react.findDOMNode)(this.refs.dialog); var sentinel = (0, _react.findDOMNode)(this.refs.sentinel); if (e.shiftKey) { if (activeElement === dialogRoot) { sentinel.focus(); } } else if (activeElement === (0, _react.findDOMNode)(this.refs.sentinel)) { dialogRoot.focus(); } } } }, onAlign: function onAlign(dialogNode) { var mousePosition = this.props.mousePosition; if (this.props.visible) { if (mousePosition) { var elOffset = offset(dialogNode); setTransformOrigin(dialogNode, mousePosition.x - elOffset.left + 'px ' + (mousePosition.y - elOffset.top) + 'px'); } else { setTransformOrigin(dialogNode, ''); } } }, getDialogElement: function getDialogElement() { var props = this.props; var closable = props.closable; var prefixCls = props.prefixCls; var dest = {}; if (props.width !== undefined) { dest.width = props.width; } if (props.height !== undefined) { dest.height = props.height; } if (props.zIndex !== undefined) { dest.zIndex = props.zIndex; } var footer = undefined; if (props.footer) { footer = _react2['default'].createElement( 'div', { className: prefixCls + '-footer' }, props.footer ); } var header = undefined; if (props.title || props.closable) { header = _react2['default'].createElement( 'div', { className: prefixCls + '-header' }, closable ? _react2['default'].createElement( 'a', { tabIndex: '0', onClick: this.close, className: prefixCls + '-close' }, _react2['default'].createElement('span', { className: prefixCls + '-close-x' }) ) : null, _react2['default'].createElement( 'div', { className: prefixCls + '-title' }, props.title ) ); } var style = (0, _objectAssign2['default'])({}, props.style, dest); var dialogProps = { className: [props.prefixCls, props.className].join(' '), tabIndex: '0', role: 'dialog', ref: 'dialog', style: style, onKeyDown: this.onKeyDown }; var transitionName = this.getTransitionName(); var dialogElement = _react2['default'].createElement( 'div', dialogProps, _react2['default'].createElement( 'div', { className: prefixCls + '-content' }, header, _react2['default'].createElement( 'div', { className: prefixCls + '-body' }, props.children ), footer ), _react2['default'].createElement( 'div', { tabIndex: '0', ref: 'sentinel', style: { width: 0, height: 0, overflow: 'hidden' } }, 'sentinel' ) ); // add key for align to keep animate children stable return _react2['default'].createElement( _rcAnimate2['default'], { key: 'dialog', showProp: 'dialogVisible', onLeave: this.onAnimateLeave, transitionName: transitionName, component: '', transitionAppear: true }, _react2['default'].createElement( _rcAlign2['default'], { align: props.align, key: 'dialog', onAlign: this.onAlign, dialogVisible: props.visible, monitorBufferTime: 80, monitorWindowResize: true, disabled: !props.visible }, dialogElement ) ); }, getMaskElement: function getMaskElement() { var props = this.props; var maskProps = { onClick: this.onMaskClick, 'data-visible': props.visible }; if (props.zIndex) { maskProps.style = { zIndex: props.zIndex }; } var maskElement = undefined; if (props.mask) { var maskTransition = this.getMaskTransitionName(); maskElement = _react2['default'].createElement('div', _extends({}, maskProps, { className: props.prefixCls + '-mask', key: 'mask' })); if (maskTransition) { maskElement = _react2['default'].createElement( _rcAnimate2['default'], { key: 'mask', showProp: 'data-visible', transitionAppear: true, component: '', transitionName: maskTransition }, maskElement ); } } return maskElement; }, getMaskTransitionName: function getMaskTransitionName() { var props = this.props; var transitionName = props.maskTransitionName; var animation = props.maskAnimation; if (!transitionName && animation) { transitionName = props.prefixCls + '-' + animation; } return transitionName; }, getTransitionName: function getTransitionName() { var props = this.props; var transitionName = props.transitionName; var animation = props.animation; if (!transitionName && animation) { transitionName = props.prefixCls + '-' + animation; } return transitionName; }, render: function render() { var _className; var props = this.props; var prefixCls = props.prefixCls; var className = (_className = {}, _defineProperty(_className, prefixCls + '-wrap', 1), _defineProperty(_className, prefixCls + '-wrap-hidden', !props.visible), _className); return _react2['default'].createElement( 'div', { className: (0, _rcUtil.classSet)(className) }, [this.getMaskElement(), this.getDialogElement()] ); }, close: function close() { this.props.onClose(); } }); exports['default'] = Dialog; module.exports = exports['default']; /***/ }, /* 197 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // export this package's api Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Align = __webpack_require__(198); var _Align2 = _interopRequireDefault(_Align); exports['default'] = _Align2['default']; module.exports = exports['default']; /***/ }, /* 198 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _domAlign = __webpack_require__(199); var _domAlign2 = _interopRequireDefault(_domAlign); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); function isWindow(obj) { /*eslint-disable eqeqeq */ return obj != null && obj == obj.window; /*eslint-enable eqeqeq */ } function buffer(fn, ms) { var timer; return function () { if (timer) { clearTimeout(timer); } timer = setTimeout(fn, ms); }; } var Align = (function (_React$Component) { _inherits(Align, _React$Component); function Align(props) { _classCallCheck(this, Align); _get(Object.getPrototypeOf(Align.prototype), 'constructor', this).apply(this, arguments); this.handleWindowResize = this.handleWindowResize.bind(this); } _createClass(Align, [{ key: 'componentDidMount', value: function componentDidMount() { var props = this.props; // if parent ref not attached .... use document.getElementById if (!props.disabled) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); if (props.monitorWindowResize) { this.startMonitorWindowResize(); } } } }, { key: 'startMonitorWindowResize', value: function startMonitorWindowResize() { if (!this.resizeHandler) { this.resizeHandler = _rcUtil2['default'].Dom.addEventListener(window, 'resize', buffer(this.handleWindowResize, this.props.monitorBufferTime)); } } }, { key: 'stopMonitorWindowResize', value: function stopMonitorWindowResize() { if (this.resizeHandler) { this.resizeHandler.remove(); this.resizeHandler = null; } } }, { key: 'handleWindowResize', value: function handleWindowResize() { var props = this.props; if (!props.disabled) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.stopMonitorWindowResize(); } }, { key: 'componentDidUpdate', value: function componentDidUpdate(prevProps) { var reAlign = false; var props = this.props; var currentTarget; if (!props.disabled) { if (prevProps.disabled || prevProps.align !== props.align) { reAlign = true; currentTarget = props.target(); } else { var lastTarget = prevProps.target(); currentTarget = props.target(); if (isWindow(lastTarget) && isWindow(currentTarget)) { reAlign = false; } else if (lastTarget !== currentTarget) { reAlign = true; } } } if (reAlign) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, currentTarget, props.align)); } if (props.monitorWindowResize && !props.disabled) { this.startMonitorWindowResize(); } else { this.stopMonitorWindowResize(); } } }, { key: 'render', value: function render() { return _react2['default'].Children.only(this.props.children); } }]); return Align; })(_react2['default'].Component); Align.defaultProps = { target: function target() { return window; }, onAlign: function onAlign() {}, monitorBufferTime: 50, monitorWindowResize: false, disabled: false }; Align.PropTypes = { align: _react2['default'].PropTypes.object.isRequired, target: _react2['default'].PropTypes.func, onAlign: _react2['default'].PropTypes.func, monitorBufferTime: _react2['default'].PropTypes.number, monitorWindowResize: _react2['default'].PropTypes.bool, disabled: _react2['default'].PropTypes.bool }; exports['default'] = Align; module.exports = exports['default']; /***/ }, /* 199 */ /***/ function(module, exports, __webpack_require__) { /** * align dom node flexibly * @author yiminghe@gmail.com */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(200); var _utils2 = _interopRequireDefault(_utils); var _getOffsetParent = __webpack_require__(201); var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); var _getVisibleRectForElement = __webpack_require__(202); var _getVisibleRectForElement2 = _interopRequireDefault(_getVisibleRectForElement); var _adjustForViewport = __webpack_require__(203); var _adjustForViewport2 = _interopRequireDefault(_adjustForViewport); var _getRegion = __webpack_require__(204); var _getRegion2 = _interopRequireDefault(_getRegion); var _getElFuturePos = __webpack_require__(205); var _getElFuturePos2 = _interopRequireDefault(_getElFuturePos); // http://yiminghe.iteye.com/blog/1124720 function isFailX(elFuturePos, elRegion, visibleRect) { return elFuturePos.left < visibleRect.left || elFuturePos.left + elRegion.width > visibleRect.right; } function isFailY(elFuturePos, elRegion, visibleRect) { return elFuturePos.top < visibleRect.top || elFuturePos.top + elRegion.height > visibleRect.bottom; } function flip(points, reg, map) { var ret = []; _utils2['default'].each(points, function (p) { ret.push(p.replace(reg, function (m) { return map[m]; })); }); return ret; } function flipOffset(offset, index) { offset[index] = -offset[index]; return offset; } function convertOffset(str, offsetLen) { var n = undefined; if (/%$/.test(str)) { n = parseInt(str.substring(0, str.length - 1), 10) / 100 * offsetLen; } else { n = parseInt(str, 10); } return n || 0; } function normalizeOffset(offset, el) { offset[0] = convertOffset(offset[0], el.width); offset[1] = convertOffset(offset[1], el.height); } /* * align node * @param {Element} node current dom node * @param {Object} align align config * * @example * { * node: null, // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素 * points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tr 与参考节点的 tl 对齐 * offset: [0, 0] // 有效值为 [n, m] * } */ function domAlign(el, refNode, align) { var points = align.points; var offset = align.offset || [0, 0]; var targetOffset = align.targetOffset || [0, 0]; var overflow = align.overflow; offset = [].concat(offset); targetOffset = [].concat(targetOffset); overflow = overflow || {}; var newOverflowCfg = {}; var fail = 0; // 当前节点可以被放置的显示区域 var visibleRect = (0, _getVisibleRectForElement2['default'])(el); // 当前节点所占的区域, left/top/width/height var elRegion = (0, _getRegion2['default'])(el); // 参照节点所占的区域, left/top/width/height var refNodeRegion = (0, _getRegion2['default'])(refNode); // 将 offset 转换成数值,支持百分比 normalizeOffset(offset, elRegion); normalizeOffset(targetOffset, refNodeRegion); // 当前节点将要被放置的位置 var elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); // 当前节点将要所处的区域 var newElRegion = _utils2['default'].merge(elRegion, elFuturePos); // 如果可视区域不能完全放置当前节点时允许调整 if (visibleRect && (overflow.adjustX || overflow.adjustY)) { if (overflow.adjustX) { // 如果横向不能放下 if (isFailX(elFuturePos, elRegion, visibleRect)) { fail = 1; // 对齐位置反下 points = flip(points, /[lr]/ig, { l: 'r', r: 'l' }); // 偏移量也反下 offset = flipOffset(offset, 0); targetOffset = flipOffset(targetOffset, 0); } } if (overflow.adjustY) { // 如果纵向不能放下 if (isFailY(elFuturePos, elRegion, visibleRect)) { fail = 1; // 对齐位置反下 points = flip(points, /[tb]/ig, { t: 'b', b: 't' }); // 偏移量也反下 offset = flipOffset(offset, 1); targetOffset = flipOffset(targetOffset, 1); } } // 如果失败,重新计算当前节点将要被放置的位置 if (fail) { elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); _utils2['default'].mix(newElRegion, elFuturePos); } // 检查反下后的位置是否可以放下了 // 如果仍然放不下只有指定了可以调整当前方向才调整 newOverflowCfg.adjustX = overflow.adjustX && isFailX(elFuturePos, elRegion, visibleRect); newOverflowCfg.adjustY = overflow.adjustY && isFailY(elFuturePos, elRegion, visibleRect); // 确实要调整,甚至可能会调整高度宽度 if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) { newElRegion = (0, _adjustForViewport2['default'])(elFuturePos, elRegion, visibleRect, newOverflowCfg); } } // https://github.com/kissyteam/kissy/issues/190 // http://localhost:8888/kissy/src/overlay/demo/other/relative_align/align.html // 相对于屏幕位置没变,而 left/top 变了 // 例如 <div 'relative'><el absolute></div> _utils2['default'].offset(el, { left: newElRegion.left, top: newElRegion.top }); // need judge to in case set fixed with in css on height auto element if (newElRegion.width !== elRegion.width) { _utils2['default'].css(el, 'width', el.width() + newElRegion.width - elRegion.width); } if (newElRegion.height !== elRegion.height) { _utils2['default'].css(el, 'height', el.height() + newElRegion.height - elRegion.height); } return { points: points, offset: offset, targetOffset: targetOffset, overflow: newOverflowCfg }; } domAlign.__getOffsetParent = _getOffsetParent2['default']; domAlign.__getVisibleRectForElement = _getVisibleRectForElement2['default']; exports['default'] = domAlign; /** * 2012-04-26 yiminghe@gmail.com * - 优化智能对齐算法 * - 慎用 resizeXX * * 2011-07-13 yiminghe@gmail.com note: * - 增加智能对齐,以及大小调整选项 **/ module.exports = exports['default']; /***/ }, /* 200 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; var getComputedStyleX = undefined; function css(el, name, v) { var value = v; if (typeof name === 'object') { for (var i in name) { if (name.hasOwnProperty(i)) { css(el, i, name[i]); } } return undefined; } if (typeof value !== 'undefined') { if (typeof value === 'number') { value = value + 'px'; } el.style[name] = value; return undefined; } return getComputedStyleX(el, name); } function getClientPosition(elem) { var box = undefined; var x = undefined; var y = undefined; var doc = elem.ownerDocument; var body = doc.body; var docElem = doc && doc.documentElement; // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 box = elem.getBoundingClientRect(); // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin x = box.left; y = box.top; // In IE, most of the time, 2 extra pixels are added to the top and left // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and // IE6 standards mode, this border can be overridden by setting the // document element's border to zero -- thus, we cannot rely on the // offset always being 2 pixels. // In quirks mode, the offset can be determined by querying the body's // clientLeft/clientTop, but in standards mode, it is found by querying // the document element's clientLeft/clientTop. Since we already called // getClientBoundingRect we have already forced a reflow, so it is not // too expensive just to query them all. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 // 窗口边框标准是设 documentElement ,quirks 时设置 body // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 // 标准 ie 下 docElem.clientTop 就是 border-top // ie7 html 即窗口边框改变不了。永远为 2 // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 x -= docElem.clientLeft || body.clientLeft || 0; y -= docElem.clientTop || body.clientTop || 0; return { left: x, top: y }; } function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; // ie6,7,8 standard mode ret = d.documentElement[method]; if (typeof ret !== 'number') { // quirks mode ret = d.body[method]; } } return ret; } function getScrollLeft(w) { return getScroll(w); } function getScrollTop(w) { return getScroll(w, true); } function getOffset(el) { var pos = getClientPosition(el); var doc = el.ownerDocument; var w = doc.defaultView || doc.parentWindow; pos.left += getScrollLeft(w); pos.top += getScrollTop(w); return pos; } function _getComputedStyle(elem, name, cs) { var computedStyle = cs; var val = ''; var d = elem.ownerDocument; // https://github.com/kissyteam/kissy/issues/61 if (computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null)) { val = computedStyle.getPropertyValue(name) || computedStyle[name]; } return val; } var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); var RE_POS = /^(top|right|bottom|left)$/; var CURRENT_STYLE = 'currentStyle'; var RUNTIME_STYLE = 'runtimeStyle'; var LEFT = 'left'; var PX = 'px'; function _getComputedStyleIE(elem, name) { // currentStyle maybe null // http://msdn.microsoft.com/en-us/library/ms535231.aspx var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 // 在 ie 下不对,需要直接用 offset 方式 // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // If we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels // exclude left right for relativity if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { // Remember the original values var style = elem.style; var left = style[LEFT]; var rsLeft = elem[RUNTIME_STYLE][LEFT]; // prevent flashing of content elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; // Put in the new values to get a computed value out style[LEFT] = name === 'fontSize' ? '1em' : ret || 0; ret = style.pixelLeft + PX; // Revert the changed values style[LEFT] = left; elem[RUNTIME_STYLE][LEFT] = rsLeft; } return ret === '' ? 'auto' : ret; } if (typeof window !== 'undefined') { getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; } // 设置 elem 相对 elem.ownerDocument 的坐标 function setOffset(elem, offset) { // set position first, in-case top/left are set even on static elem if (css(elem, 'position') === 'static') { elem.style.position = 'relative'; } var preset = -9999; if ('left' in offset) { elem.style.left = preset + 'px'; } if ('top' in offset) { elem.style.top = preset + 'px'; } var old = getOffset(elem); var ret = {}; var key = undefined; for (key in offset) { if (offset.hasOwnProperty(key)) { ret[key] = preset + offset[key] - old[key]; } } css(elem, ret); } function each(arr, fn) { for (var i = 0; i < arr.length; i++) { fn(arr[i]); } } function isBorderBoxFn(elem) { return getComputedStyleX(elem, 'boxSizing') === 'border-box'; } var BOX_MODELS = ['margin', 'border', 'padding']; var CONTENT_INDEX = -1; var PADDING_INDEX = 2; var BORDER_INDEX = 1; var MARGIN_INDEX = 0; function swap(elem, options, callback) { var old = {}; var style = elem.style; var name = undefined; // Remember the old values, and insert the new ones for (name in options) { if (options.hasOwnProperty(name)) { old[name] = style[name]; style[name] = options[name]; } } callback.call(elem); // Revert the old values for (name in options) { if (options.hasOwnProperty(name)) { style[name] = old[name]; } } } function getPBMWidth(elem, props, which) { var value = 0; var prop = undefined; var j = undefined; var i = undefined; for (j = 0; j < props.length; j++) { prop = props[j]; if (prop) { for (i = 0; i < which.length; i++) { var cssProp = undefined; if (prop === 'border') { cssProp = prop + which[i] + 'Width'; } else { cssProp = prop + which[i]; } value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; } } } return value; } /** * A crude way of determining if an object is a window * @member util */ function isWindow(obj) { // must use == for ie8 /* eslint eqeqeq:0 */ return obj !== null && obj !== undefined && obj == obj.window; } var domUtils = {}; each(['Width', 'Height'], function (name) { domUtils['doc' + name] = function (refWin) { var d = refWin.document; return Math.max( // firefox chrome documentElement.scrollHeight< body.scrollHeight // ie standard mode : documentElement.scrollHeight> body.scrollHeight d.documentElement['scroll' + name], // quirks : documentElement.scrollHeight 最大等于可视窗口多一点? d.body['scroll' + name], domUtils['viewport' + name](d)); }; domUtils['viewport' + name] = function (win) { // pc browser includes scrollbar in window.innerWidth var prop = 'client' + name; var doc = win.document; var body = doc.body; var documentElement = doc.documentElement; var documentElementProp = documentElement[prop]; // 标准模式取 documentElement // backcompat 取 body return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp; }; }); /* 得到元素的大小信息 @param elem @param name @param {String} [extra] 'padding' : (css width) + padding 'border' : (css width) + padding + border 'margin' : (css width) + padding + border + margin */ function getWH(elem, name, ex) { var extra = ex; if (isWindow(elem)) { return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); } else if (elem.nodeType === 9) { return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); } var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem, computedStyle); var cssBoxValue = 0; if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) { borderBoxValue = undefined; // Fall back to computed then un computed css if necessary cssBoxValue = getComputedStyleX(elem, name); if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) { cssBoxValue = elem.style[name] || 0; } // Normalize '', auto, and prepare for extra cssBoxValue = parseFloat(cssBoxValue) || 0; } if (extra === undefined) { extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; } var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; var val = borderBoxValue || cssBoxValue; if (extra === CONTENT_INDEX) { if (borderBoxValueOrIsBorderBox) { return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle); } return cssBoxValue; } else if (borderBoxValueOrIsBorderBox) { if (extra === BORDER_INDEX) { return val; } return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle)); } return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle); } var cssShow = { position: 'absolute', visibility: 'hidden', display: 'block' }; // fix #119 : https://github.com/kissyteam/kissy/issues/119 function getWHIgnoreDisplay() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var val = undefined; var elem = args[0]; // in case elem is window // elem.offsetWidth === undefined if (elem.offsetWidth !== 0) { val = getWH.apply(undefined, args); } else { swap(elem, cssShow, function () { val = getWH.apply(undefined, args); }); } return val; } each(['width', 'height'], function (name) { var first = name.charAt(0).toUpperCase() + name.slice(1); domUtils['outer' + first] = function (el, includeMargin) { return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); }; var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; domUtils[name] = function (elem, v) { var val = v; if (val !== undefined) { if (elem) { var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem); if (isBorderBox) { val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); } return css(elem, name, val); } return undefined; } return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); }; }); function mix(to, from) { for (var i in from) { if (from.hasOwnProperty(i)) { to[i] = from[i]; } } return to; } var utils = { getWindow: function getWindow(node) { if (node && node.document && node.setTimeout) { return node; } var doc = node.ownerDocument || node; return doc.defaultView || doc.parentWindow; }, offset: function offset(el, value) { if (typeof value !== 'undefined') { setOffset(el, value); } else { return getOffset(el); } }, isWindow: isWindow, each: each, css: css, clone: function clone(obj) { var i = undefined; var ret = {}; for (i in obj) { if (obj.hasOwnProperty(i)) { ret[i] = obj[i]; } } var overflow = obj.overflow; if (overflow) { for (i in obj) { if (obj.hasOwnProperty(i)) { ret.overflow[i] = obj.overflow[i]; } } } return ret; }, mix: mix, getWindowScrollLeft: function getWindowScrollLeft(w) { return getScrollLeft(w); }, getWindowScrollTop: function getWindowScrollTop(w) { return getScrollTop(w); }, merge: function merge() { var ret = {}; for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } for (var i = 0; i < args.length; i++) { utils.mix(ret, args[i]); } return ret; }, viewportWidth: 0, viewportHeight: 0 }; mix(utils, domUtils); exports['default'] = utils; module.exports = exports['default']; /***/ }, /* 201 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(200); var _utils2 = _interopRequireDefault(_utils); /** * 得到会导致元素显示不全的祖先元素 */ function getOffsetParent(element) { // ie 这个也不是完全可行 /* <div style="width: 50px;height: 100px;overflow: hidden"> <div style="width: 50px;height: 100px;position: relative;" id="d6"> 元素 6 高 100px 宽 50px<br/> </div> </div> */ // element.offsetParent does the right thing in ie7 and below. Return parent with layout! // In other browsers it only includes elements with position absolute, relative or // fixed, not elements with overflow set to auto or scroll. // if (UA.ie && ieMode < 8) { // return element.offsetParent; // } // 统一的 offsetParent 方法 var doc = element.ownerDocument; var body = doc.body; var parent = undefined; var positionStyle = _utils2['default'].css(element, 'position'); var skipStatic = positionStyle === 'fixed' || positionStyle === 'absolute'; if (!skipStatic) { return element.nodeName.toLowerCase() === 'html' ? null : element.parentNode; } for (parent = element.parentNode; parent && parent !== body; parent = parent.parentNode) { positionStyle = _utils2['default'].css(parent, 'position'); if (positionStyle !== 'static') { return parent; } } return null; } exports['default'] = getOffsetParent; module.exports = exports['default']; /***/ }, /* 202 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(200); var _utils2 = _interopRequireDefault(_utils); var _getOffsetParent = __webpack_require__(201); var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); /** * 获得元素的显示部分的区域 */ function getVisibleRectForElement(element) { var visibleRect = { left: 0, right: Infinity, top: 0, bottom: Infinity }; var el = (0, _getOffsetParent2['default'])(element); var scrollX = undefined; var scrollY = undefined; var winSize = undefined; var doc = element.ownerDocument; var win = doc.defaultView || doc.parentWindow; var body = doc.body; var documentElement = doc.documentElement; // Determine the size of the visible rect by climbing the dom accounting for // all scrollable containers. while (el) { // clientWidth is zero for inline block elements in ie. if ((navigator.userAgent.indexOf('MSIE') === -1 || el.clientWidth !== 0) && ( // body may have overflow set on it, yet we still get the entire // viewport. In some browsers, el.offsetParent may be // document.documentElement, so check for that too. el !== body && el !== documentElement && _utils2['default'].css(el, 'overflow') !== 'visible')) { var pos = _utils2['default'].offset(el); // add border pos.left += el.clientLeft; pos.top += el.clientTop; visibleRect.top = Math.max(visibleRect.top, pos.top); visibleRect.right = Math.min(visibleRect.right, // consider area without scrollBar pos.left + el.clientWidth); visibleRect.bottom = Math.min(visibleRect.bottom, pos.top + el.clientHeight); visibleRect.left = Math.max(visibleRect.left, pos.left); } else if (el === body || el === documentElement) { break; } el = (0, _getOffsetParent2['default'])(el); } // Clip by window's viewport. scrollX = _utils2['default'].getWindowScrollLeft(win); scrollY = _utils2['default'].getWindowScrollTop(win); visibleRect.left = Math.max(visibleRect.left, scrollX); visibleRect.top = Math.max(visibleRect.top, scrollY); winSize = { width: _utils2['default'].viewportWidth(win), height: _utils2['default'].viewportHeight(win) }; visibleRect.right = Math.min(visibleRect.right, scrollX + winSize.width); visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + winSize.height); return visibleRect.top >= 0 && visibleRect.left >= 0 && visibleRect.bottom > visibleRect.top && visibleRect.right > visibleRect.left ? visibleRect : null; } exports['default'] = getVisibleRectForElement; module.exports = exports['default']; /***/ }, /* 203 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(200); var _utils2 = _interopRequireDefault(_utils); function adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) { var pos = _utils2['default'].clone(elFuturePos); var size = { width: elRegion.width, height: elRegion.height }; if (overflow.adjustX && pos.left < visibleRect.left) { pos.left = visibleRect.left; } // Left edge inside and right edge outside viewport, try to resize it. if (overflow.resizeWidth && pos.left >= visibleRect.left && pos.left + size.width > visibleRect.right) { size.width -= pos.left + size.width - visibleRect.right; } // Right edge outside viewport, try to move it. if (overflow.adjustX && pos.left + size.width > visibleRect.right) { // 保证左边界和可视区域左边界对齐 pos.left = Math.max(visibleRect.right - size.width, visibleRect.left); } // Top edge outside viewport, try to move it. if (overflow.adjustY && pos.top < visibleRect.top) { pos.top = visibleRect.top; } // Top edge inside and bottom edge outside viewport, try to resize it. if (overflow.resizeHeight && pos.top >= visibleRect.top && pos.top + size.height > visibleRect.bottom) { size.height -= pos.top + size.height - visibleRect.bottom; } // Bottom edge outside viewport, try to move it. if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) { // 保证上边界和可视区域上边界对齐 pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top); } return _utils2['default'].mix(pos, size); } exports['default'] = adjustForViewport; module.exports = exports['default']; /***/ }, /* 204 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(200); var _utils2 = _interopRequireDefault(_utils); function getRegion(node) { var offset = undefined; var w = undefined; var h = undefined; if (!_utils2['default'].isWindow(node) && node.nodeType !== 9) { offset = _utils2['default'].offset(node); w = _utils2['default'].outerWidth(node); h = _utils2['default'].outerHeight(node); } else { var win = _utils2['default'].getWindow(node); offset = { left: _utils2['default'].getWindowScrollLeft(win), top: _utils2['default'].getWindowScrollTop(win) }; w = _utils2['default'].viewportWidth(win); h = _utils2['default'].viewportHeight(win); } offset.width = w; offset.height = h; return offset; } exports['default'] = getRegion; module.exports = exports['default']; /***/ }, /* 205 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _getAlignOffset = __webpack_require__(206); var _getAlignOffset2 = _interopRequireDefault(_getAlignOffset); function getElFuturePos(elRegion, refNodeRegion, points, offset, targetOffset) { var xy = undefined; var diff = undefined; var p1 = undefined; var p2 = undefined; xy = { left: elRegion.left, top: elRegion.top }; p1 = (0, _getAlignOffset2['default'])(refNodeRegion, points[1]); p2 = (0, _getAlignOffset2['default'])(elRegion, points[0]); diff = [p2.left - p1.left, p2.top - p1.top]; return { left: xy.left - diff[0] + offset[0] - targetOffset[0], top: xy.top - diff[1] + offset[1] - targetOffset[1] }; } exports['default'] = getElFuturePos; module.exports = exports['default']; /***/ }, /* 206 */ /***/ function(module, exports) { /** * 获取 node 上的 align 对齐点 相对于页面的坐标 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function getAlignOffset(region, align) { var V = align.charAt(0); var H = align.charAt(1); var w = region.width; var h = region.height; var x = undefined; var y = undefined; x = region.left; y = region.top; if (V === 'c') { y += h / 2; } else if (V === 'b') { y += h; } if (H === 'c') { x += w / 2; } else if (H === 'r') { x += w; } return { left: x, top: y }; } exports['default'] = getAlignOffset; module.exports = exports['default']; /***/ }, /* 207 */ /***/ function(module, exports) { 'use strict'; function ToObject(val) { if (val == null) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } module.exports = Object.assign || function (target, source) { var from; var keys; var to = ToObject(target); for (var s = 1; s < arguments.length; s++) { from = arguments[s]; keys = Object.keys(Object(from)); for (var i = 0; i < keys.length; i++) { to[keys[i]] = from[keys[i]]; } } return to; }; /***/ }, /* 208 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _index = __webpack_require__(193); var _index2 = _interopRequireDefault(_index); exports['default'] = function (props) { var div = document.createElement('div'); document.body.appendChild(div); var d = undefined; props = props || {}; props.iconClassName = props.iconClassName || 'anticon-question-circle'; var width = props.width || 416; // 默认为 true,保持向下兼容 if (!('okCancel' in props)) { props.okCancel = true; } function close() { d.setState({ visible: false }); _react2['default'].unmountComponentAtNode(div); } function onCancel() { var cancelFn = props.onCancel; if (cancelFn) { var ret = undefined; if (cancelFn.length) { ret = cancelFn(close); } else { ret = cancelFn(); if (!ret) { close(); } } if (ret && ret.then) { ret.then(close); } } else { close(); } } function onOk() { var okFn = props.onOk; if (okFn) { var ret = undefined; if (okFn.length) { ret = okFn(close); } else { ret = okFn(); if (!ret) { close(); } } if (ret && ret.then) { ret.then(close); } } else { close(); } } var body = _react2['default'].createElement( 'div', { className: 'ant-confirm-body' }, _react2['default'].createElement('i', { className: 'anticon ' + props.iconClassName }), _react2['default'].createElement( 'span', { className: 'ant-confirm-title' }, props.title ), _react2['default'].createElement( 'div', { className: 'ant-confirm-content' }, props.content ) ); var footer = _react2['default'].createElement( 'div', { className: 'ant-confirm-btns' }, _react2['default'].createElement( 'button', { type: 'button', className: 'ant-btn-default ant-btn ant-btn-lg', onClick: onCancel }, '取 消' ), _react2['default'].createElement( 'button', { type: 'button', className: 'ant-btn-primary ant-btn ant-btn-lg', onClick: onOk }, '确 定' ) ); if (props.okCancel) { footer = _react2['default'].createElement( 'div', { className: 'ant-confirm-btns' }, _react2['default'].createElement( 'button', { type: 'button', className: 'ant-btn-default ant-btn ant-btn-lg', onClick: onCancel }, '取 消' ), _react2['default'].createElement( 'button', { type: 'button', className: 'ant-btn-primary ant-btn ant-btn-lg', onClick: onOk }, '确 定' ) ); } else { footer = _react2['default'].createElement( 'div', { className: 'ant-confirm-btns' }, _react2['default'].createElement( 'button', { type: 'button', className: 'ant-btn-primary ant-btn ant-btn-lg', onClick: onOk }, '知道了' ) ); } _react2['default'].render(_react2['default'].createElement( _index2['default'], { prefixCls: 'ant-modal', className: 'ant-confirm', visible: true, closable: false, title: '', transitionName: 'zoom', footer: '', maskTransitionName: 'fade', width: width }, _react2['default'].createElement( 'div', { style: { zoom: 1, overflow: 'hidden' } }, body, ' ', footer ) ), div, function () { d = this; }); }; module.exports = exports['default']; /***/ }, /* 209 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcDropdown = __webpack_require__(210); var _rcDropdown2 = _interopRequireDefault(_rcDropdown); exports['default'] = _react2['default'].createClass({ displayName: 'index', getDefaultProps: function getDefaultProps() { return { transitionName: 'slide-up', prefixCls: 'ant-dropdown' }; }, render: function render() { return _react2['default'].createElement(_rcDropdown2['default'], this.props); } }); module.exports = exports['default']; /***/ }, /* 210 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Dropdown = __webpack_require__(211); var _Dropdown2 = _interopRequireDefault(_Dropdown); exports['default'] = _Dropdown2['default']; module.exports = exports['default']; /***/ }, /* 211 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcTooltip = __webpack_require__(137); var _rcTooltip2 = _interopRequireDefault(_rcTooltip); /* var MenuItem = Menu.Item; var menu = <Menu><MenuItem>1</MenuItem></Menu>; <DropDown trigger="click" animationName="" overlay={<>} onSelect={}> <button>open</button> </DropDown> */ var Dropdown = _react2['default'].createClass({ displayName: 'Dropdown', propTypes: { minOverlayWidthMatchTrigger: _react2['default'].PropTypes.bool }, getDefaultProps: function getDefaultProps() { return { minOverlayWidthMatchTrigger: true, prefixCls: 'rc-dropdown', defaultVisible: false, onVisibleChange: function onVisibleChange() {}, placement: { points: ['tl', 'bl'] } }; }, getInitialState: function getInitialState() { var props = this.props; if ('visible' in props) { return { visible: props.visible }; } return { visible: props.defaultVisible }; }, componentWillReceiveProps: function componentWillReceiveProps(props) { if ('visible' in props) { this.setState({ visible: props.visible }); } }, onClick: function onClick(e) { var props = this.props; var overlayProps = props.overlay.props; if (!('visible' in props)) { this.setState({ visible: false }); } if (overlayProps.onClick) { overlayProps.onClick(e); } }, onVisibleChange: function onVisibleChange(v) { var props = this.props; if (!('visible' in props)) { this.setState({ visible: v }); } props.onVisibleChange(v); }, getMenuElement: function getMenuElement() { var props = this.props; return _react2['default'].cloneElement(props.overlay, { prefixCls: props.prefixCls + '-menu', onClick: this.onClick }); }, render: function render() { return _react2['default'].createElement(_rcTooltip2['default'], _extends({}, this.props, { ref: 'tooltip', visible: this.state.visible, afterVisibleChange: this.afterVisibleChange, overlay: this.getMenuElement(), onVisibleChange: this.onVisibleChange })); }, afterVisibleChange: function afterVisibleChange(visible) { if (visible && this.props.minOverlayWidthMatchTrigger) { var overlayNode = _react2['default'].findDOMNode(this.refs.tooltip.popupInstance); var rootNode = _react2['default'].findDOMNode(this); if (rootNode.offsetWidth > overlayNode.offsetWidth) { overlayNode.style.width = rootNode.offsetWidth + 'px'; } } } }); exports['default'] = Dropdown; module.exports = exports['default']; /***/ }, /* 212 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rcProgress = __webpack_require__(213); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _objectAssign = __webpack_require__(184); var _objectAssign2 = _interopRequireDefault(_objectAssign); var prefixCls = 'ant-progress'; var statusColorMap = { 'normal': '#2db7f5', 'exception': '#ff6600', 'success': '#87d068' }; var Line = _react2['default'].createClass({ displayName: 'Line', propTypes: { status: _react2['default'].PropTypes.oneOf(['normal', 'exception', 'active', 'success']), showInfo: _react2['default'].PropTypes.bool, percent: _react2['default'].PropTypes.number, strokeWidth: _react2['default'].PropTypes.number }, getDefaultProps: function getDefaultProps() { return { percent: 0, strokeWidth: 10, status: 'normal', // exception active showInfo: true }; }, render: function render() { var props = (0, _objectAssign2['default'])({}, this.props); if (parseInt(props.percent, 10) === 100) { props.status = 'success'; } var progressInfo = undefined; var fullCls = ''; if (props.showInfo === true) { if (props.status === 'exception') { progressInfo = _react2['default'].createElement( 'span', { className: prefixCls + '-line-text' }, _react2['default'].createElement('i', { className: 'anticon anticon-exclamation-circle' }) ); } else if (props.status === 'success') { progressInfo = _react2['default'].createElement( 'span', { className: prefixCls + '-line-text' }, _react2['default'].createElement('i', { className: 'anticon anticon-check-circle' }) ); } else { progressInfo = _react2['default'].createElement( 'span', { className: prefixCls + '-line-text' }, props.percent, '%' ); } } else { fullCls = ' ' + prefixCls + '-line-wrap-full'; } var percentStyle = { width: props.percent + '%', height: props.strokeWidth }; return _react2['default'].createElement( 'div', { className: prefixCls + '-line-wrap clearfix status-' + props.status + fullCls }, progressInfo, _react2['default'].createElement( 'div', { className: prefixCls + '-line-outer' }, _react2['default'].createElement( 'div', { className: prefixCls + '-line-inner' }, _react2['default'].createElement('div', { className: prefixCls + '-line-bg', style: percentStyle }) ) ) ); } }); var Circle = _react2['default'].createClass({ displayName: 'Circle', getDefaultProps: function getDefaultProps() { return { width: 132, percent: 0, strokeWidth: 6, status: 'normal' // exception }; }, render: function render() { var props = (0, _objectAssign2['default'])({}, this.props); if (parseInt(props.percent, 10) === 100) { props.status = 'success'; } var style = { 'width': props.width, 'height': props.width, 'fontSize': props.width * 0.16 + 6 }; var progressInfo = undefined; if (props.status === 'exception') { progressInfo = _react2['default'].createElement( 'span', { className: prefixCls + '-circle-text' }, _react2['default'].createElement('i', { className: 'anticon anticon-exclamation' }) ); } else if (props.status === 'success') { progressInfo = _react2['default'].createElement( 'span', { className: prefixCls + '-circle-text' }, _react2['default'].createElement('i', { className: 'anticon anticon-check' }) ); } else { progressInfo = _react2['default'].createElement( 'span', { className: prefixCls + '-circle-text' }, props.percent, '%' ); } return _react2['default'].createElement( 'div', { className: prefixCls + '-circle-wrap status-' + props.status }, _react2['default'].createElement( 'div', { className: prefixCls + '-circle-inner', style: style }, _react2['default'].createElement(_rcProgress.Circle, { percent: props.percent, strokeWidth: props.strokeWidth, strokeColor: statusColorMap[props.status], trailColor: '#e9e9e9' }), progressInfo ) ); } }); exports['default'] = { Line: Line, Circle: Circle }; module.exports = exports['default']; /***/ }, /* 213 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(214); /***/ }, /* 214 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var assign = __webpack_require__(215); var React = __webpack_require__(76); var defaultProps = { strokeWidth: 1, strokeColor: '#3FC7FA', trailWidth: 1, trailColor: '#D9D9D9' }; var Line = React.createClass({ displayName: 'Line', render: function render() { var props = assign({}, this.props); var pathStyle = { 'strokeDasharray': '100px, 100px', 'strokeDashoffset': '' + (100 - props.percent) + 'px', 'transition': 'stroke-dashoffset 0.6s ease 0s, stroke 0.6s linear' }; ['strokeWidth', 'strokeColor', 'trailWidth', 'trailColor'].forEach(function (item) { if (item === 'trailWidth' && !props.trailWidth && props.strokeWidth) { props.trailWidth = props.strokeWidth; return; } if (item === 'strokeWidth' && props.strokeWidth && (!parseFloat(props.strokeWidth) || parseFloat(props.strokeWidth) > 100 || parseFloat(props.strokeWidth) < 0)) { props[item] = defaultProps[item]; return; } if (!props[item]) { props[item] = defaultProps[item]; } }); var strokeWidth = props.strokeWidth; var center = strokeWidth / 2; var right = 100 - strokeWidth / 2; var pathString = 'M ' + center + ',' + center + ' L ' + right + ',' + center; var viewBoxString = '0 0 100 ' + strokeWidth; return React.createElement( 'svg', { className: 'rc-progress-line', viewBox: viewBoxString, preserveAspectRatio: 'none' }, React.createElement('path', { className: 'rc-progress-line-trail', d: pathString, strokeLinecap: 'round', stroke: props.trailColor, strokeWidth: props.trailWidth, fillOpacity: '0' }), React.createElement('path', { className: 'rc-progress-line-path', d: pathString, strokeLinecap: 'round', stroke: props.strokeColor, strokeWidth: props.strokeWidth, fillOpacity: '0', style: pathStyle }) ); } }); var Circle = React.createClass({ displayName: 'Circle', render: function render() { var props = assign({}, this.props); var strokeWidth = props.strokeWidth; var radius = 50 - strokeWidth / 2; var pathString = 'M 50,50 m 0,-' + radius + '\n a ' + radius + ',' + radius + ' 0 1 1 0,' + 2 * radius + '\n a ' + radius + ',' + radius + ' 0 1 1 0,-' + 2 * radius; var len = Math.PI * 2 * radius; var pathStyle = { 'strokeDasharray': '' + len + 'px ' + len + 'px', 'strokeDashoffset': '' + (100 - props.percent) / 100 * len + 'px', 'transition': 'stroke-dashoffset 0.6s ease 0s, stroke 0.6s ease' }; ['strokeWidth', 'strokeColor', 'trailWidth', 'trailColor'].forEach(function (item) { if (item === 'trailWidth' && !props.trailWidth && props.strokeWidth) { props.trailWidth = props.strokeWidth; return; } if (!props[item]) { props[item] = defaultProps[item]; } }); return React.createElement( 'svg', { className: 'rc-progress-circle', viewBox: '0 0 100 100' }, React.createElement('path', { className: 'rc-progress-circle-trail', d: pathString, stroke: props.trailColor, strokeWidth: props.trailWidth, fillOpacity: '0' }), React.createElement('path', { className: 'rc-progress-circle-path', d: pathString, strokeLinecap: 'round', stroke: props.strokeColor, strokeWidth: props.strokeWidth, fillOpacity: '0', style: pathStyle }) ); } }); module.exports = { Line: Line, Circle: Circle }; /***/ }, /* 215 */ /***/ function(module, exports) { 'use strict'; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function ToObject(val) { if (val == null) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function ownEnumerableKeys(obj) { var keys = Object.getOwnPropertyNames(obj); if (Object.getOwnPropertySymbols) { keys = keys.concat(Object.getOwnPropertySymbols(obj)); } return keys.filter(function (key) { return propIsEnumerable.call(obj, key); }); } module.exports = Object.assign || function (target, source) { var from; var keys; var to = ToObject(target); for (var s = 1; s < arguments.length; s++) { from = arguments[s]; keys = ownEnumerableKeys(Object(from)); for (var i = 0; i < keys.length; i++) { to[keys[i]] = from[keys[i]]; } } return to; }; /***/ }, /* 216 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcTooltip = __webpack_require__(137); var _rcTooltip2 = _interopRequireDefault(_rcTooltip); var prefixCls = 'ant-popover'; exports['default'] = _react2['default'].createClass({ displayName: 'index', getDefaultProps: function getDefaultProps() { return { prefixCls: prefixCls, placement: 'top', trigger: 'hover', mouseEnterDelay: 0.1, mouseLeaveDelay: 0.1, overlayStyle: {} }; }, render: function render() { var overlay = _react2['default'].createElement( 'div', null, _react2['default'].createElement( 'div', { className: prefixCls + '-title' }, this.props.title ), _react2['default'].createElement( 'div', { className: prefixCls + '-content' }, this.props.overlay ) ); var transitionName = ({ top: 'zoom-down', bottom: 'zoom-up', left: 'zoom-right', right: 'zoom-left' })[this.props.placement]; return _react2['default'].createElement( _rcTooltip2['default'], _extends({ transitionName: transitionName }, this.props, { overlay: overlay }), this.props.children ); } }); module.exports = exports['default']; /***/ }, /* 217 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcSelect = __webpack_require__(218); var _rcSelect2 = _interopRequireDefault(_rcSelect); var AntSelect = _react2['default'].createClass({ displayName: 'AntSelect', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-select', transitionName: 'slide-up', optionLabelProp: 'children', showSearch: false }; }, render: function render() { var sizeClass = ''; if (this.props.size === 'large') { sizeClass = 'ant-select-lg'; } else if (this.props.size === 'small') { sizeClass = 'ant-select-sm'; } var className = this.props.className || ' '; var notFoundContent = this.props.notFoundContent; if (this.props.combobox) { notFoundContent = null; } return _react2['default'].createElement(_rcSelect2['default'], _extends({}, this.props, { className: className + sizeClass, notFoundContent: notFoundContent })); } }); AntSelect.Option = _rcSelect2['default'].Option; AntSelect.OptGroup = _rcSelect2['default'].OptGroup; exports['default'] = AntSelect; module.exports = exports['default']; /***/ }, /* 218 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Select = __webpack_require__(219); var _Select2 = _interopRequireDefault(_Select); var _Option = __webpack_require__(248); var _Option2 = _interopRequireDefault(_Option); var _OptGroup = __webpack_require__(220); var _OptGroup2 = _interopRequireDefault(_OptGroup); _Select2['default'].Option = _Option2['default']; _Select2['default'].OptGroup = _OptGroup2['default']; exports['default'] = _Select2['default']; module.exports = exports['default']; /***/ }, /* 219 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _OptGroup = __webpack_require__(220); var _OptGroup2 = _interopRequireDefault(_OptGroup); var _Dropdown = __webpack_require__(221); var _Dropdown2 = _interopRequireDefault(_Dropdown); var _util = __webpack_require__(222); function noop() {} function filterFn(input, child) { return String((0, _util.getPropValue)(child, this.props.optionFilterProp)).indexOf(input) > -1; } function saveRef(name, component) { this[name] = component; } var Select = _react2['default'].createClass({ displayName: 'Select', propTypes: { multiple: _react.PropTypes.bool, filterOption: _react.PropTypes.any, showSearch: _react.PropTypes.bool, disabled: _react.PropTypes.bool, showArrow: _react.PropTypes.bool, tags: _react.PropTypes.bool, transitionName: _react.PropTypes.string, optionLabelProp: _react.PropTypes.string, optionFilterProp: _react.PropTypes.string, animation: _react.PropTypes.string, onChange: _react.PropTypes.func, onSelect: _react.PropTypes.func, onSearch: _react.PropTypes.func, searchPlaceholder: _react.PropTypes.string, placeholder: _react.PropTypes.any, onDeselect: _react.PropTypes.func, value: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.string]), defaultValue: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.string]), label: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.any]), defaultLabel: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.any]), dropdownStyle: _react.PropTypes.object, maxTagTextLength: _react.PropTypes.number }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-select', filterOption: filterFn, showSearch: true, allowClear: false, placeholder: '', searchPlaceholder: '', defaultValue: [], onChange: noop, onSelect: noop, onSearch: noop, onDeselect: noop, showArrow: true, dropdownMatchSelectWidth: true, dropdownStyle: {}, dropdownMenuStyle: {}, optionFilterProp: 'value', optionLabelProp: 'value', notFoundContent: 'Not Found' }; }, getInitialState: function getInitialState() { var props = this.props; var value = []; if ('value' in props) { value = (0, _util.toArray)(props.value); } else { value = (0, _util.toArray)(props.defaultValue); } var label = this.getLabelFromProps(props, value, 1); var inputValue = ''; if (props.combobox) { inputValue = value[0] || ''; } this.saveInputRef = saveRef.bind(this, 'inputInstance'); this.saveDropdownRef = saveRef.bind(this, 'dropdownInstance'); return { value: value, inputValue: inputValue, label: label }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('value' in nextProps) { var value = (0, _util.toArray)(nextProps.value); var label = this.getLabelFromProps(nextProps, value); this.setState({ value: value, label: label }); if (nextProps.combobox) { this.setState({ inputValue: value[0] || '' }); } } }, componentDidUpdate: function componentDidUpdate() { var state = this.state; var props = this.props; if (this.haveOpened) { _react2['default'].render(this.getDropdownElement(), this.getDropdownContainer()); } if (state.open) { if (props.dropdownMatchSelectWidth) { var dropdownDOMNode = this.getDropdownDOMNode(); if (dropdownDOMNode) { dropdownDOMNode.style.width = this.getDOMNode().offsetWidth + 'px'; } } if ((0, _util.isMultipleOrTags)(props)) { var inputNode = this.getInputDOMNode(); if (inputNode.value) { inputNode.style.width = ''; inputNode.style.width = inputNode.scrollWidth + 'px'; } else { inputNode.style.width = ''; } } } }, componentWillUnmount: function componentWillUnmount() { if (this.dropdownContainer) { _react2['default'].unmountComponentAtNode(this.dropdownContainer); document.body.removeChild(this.dropdownContainer); this.dropdownContainer = null; } this.dropdownInstance = null; if (this._blurTimer) { clearTimeout(this._blurTimer); this._blurTimer = null; } }, onInputChange: function onInputChange(e) { var val = e.target.value; var props = this.props; this.setState({ inputValue: val, open: true }); if ((0, _util.isCombobox)(props)) { this.fireChange([val], [val]); } props.onSearch(val); }, onClick: function onClick() { var props = this.props; if (!props.disabled) { if (this.state.open) { this.setOpenState(false); } else { this.openIfHasChildren(); if ((0, _util.isMultipleOrTagsOrCombobox)(props)) { if (this.getInputDOMNode()) { this.getInputDOMNode().focus(); } } } } }, // combobox ignore onKeyDown: function onKeyDown(e) { var props = this.props; if (props.disabled) { return; } var keyCode = e.keyCode; if (this.state.open && !this.getInputDOMNode()) { this.onInputKeyDown(e); } else if (keyCode === _rcUtil.KeyCode.ENTER || keyCode === _rcUtil.KeyCode.DOWN) { this.onClick(); e.preventDefault(); } }, onInputKeyDown: function onInputKeyDown(e) { var props = this.props; var state = this.state; var keyCode = e.keyCode; if ((0, _util.isMultipleOrTags)(props) && !e.target.value && keyCode === _rcUtil.KeyCode.BACKSPACE) { var value = state.value.concat(); if (value.length) { var label = state.label.concat(); var popValue = value.pop(); label.pop(); props.onDeselect(popValue); this.fireChange(value, label); } return; } if (keyCode === _rcUtil.KeyCode.DOWN) { if (!state.open) { this.openIfHasChildren(); e.preventDefault(); e.stopPropagation(); return; } } else if (keyCode === _rcUtil.KeyCode.ESC) { if (state.open) { this.setOpenState(false); e.preventDefault(); e.stopPropagation(); } return; } if (state.open) { var menu = this.dropdownInstance && this.dropdownInstance.getMenuComponent(); if (menu && menu.onKeyDown(e)) { e.preventDefault(); e.stopPropagation(); } } }, onMenuSelect: function onMenuSelect(_ref) { var item = _ref.item; var value = this.state.value; var label = this.state.label; var props = this.props; var selectedValue = (0, _util.getValuePropValue)(item); var selectedLabel = this.getLabelFromOption(item); props.onSelect(selectedValue, item); if ((0, _util.isMultipleOrTags)(props)) { if (value.indexOf(selectedValue) !== -1) { return; } value = value.concat([selectedValue]); label = label.concat([selectedLabel]); } else { if (value[0] === selectedValue) { this.setOpenState(false); return; } value = [selectedValue]; label = [selectedLabel]; } this.fireChange(value, label); this.setOpenState(false); this.setState({ inputValue: '' }); if ((0, _util.isCombobox)(props)) { this.setState({ inputValue: (0, _util.getPropValue)(item, props.optionLabelProp) }); } }, onMenuDeselect: function onMenuDeselect(_ref2) { var item = _ref2.item; var domEvent = _ref2.domEvent; if (domEvent.type === 'click') { this.removeSelected((0, _util.getValuePropValue)(item)); } this.setOpenState(false); this.setState({ inputValue: '' }); }, onBlur: function onBlur() { var _this = this; if (this._blurTimer) { clearTimeout(this._blurTimer); } this._blurTimer = setTimeout(function () { _this.setState({ open: false }); }, 100); }, onFocus: function onFocus() { if (this._blurTimer) { clearTimeout(this._blurTimer); this._blurTimer = null; } }, onPlaceholderClick: function onPlaceholderClick() { this.getInputDOMNode().focus(); }, onClearSelection: function onClearSelection(e) { var props = this.props; var state = this.state; if (props.disabled) { return; } e.stopPropagation(); if (state.inputValue || state.value.length) { this.fireChange([], []); this.setOpenState(false); this.setState({ inputValue: '' }); } }, getLabelBySingleValue: function getLabelBySingleValue(children, value) { var _this2 = this; if (value === undefined) { return null; } var label = null; _react2['default'].Children.forEach(children, function (c) { if (c.type === _OptGroup2['default']) { var maybe = _this2.getLabelBySingleValue(c.props.children, value); if (maybe !== null) { label = maybe; } } else if ((0, _util.getValuePropValue)(c) === value) { label = _this2.getLabelFromOption(c); } }); return label; }, getLabelFromOption: function getLabelFromOption(c) { return (0, _util.getPropValue)(c, this.props.optionLabelProp); }, getLabelFromProps: function getLabelFromProps(props, value, init) { var label = []; if ('label' in props) { label = (0, _util.toArray)(props.label); } else if (init && 'defaultLabel' in props) { label = (0, _util.toArray)(props.defaultLabel); } else { label = this.getLabelByValue(props.children, value); } return label; }, getVLForOnChange: function getVLForOnChange(vls) { if (vls !== undefined) { return (0, _util.isMultipleOrTags)(this.props) ? vls : vls[0]; } return vls; }, getLabelByValue: function getLabelByValue(children, value) { var _this3 = this; return value.map(function (v) { var label = _this3.getLabelBySingleValue(children, v); if (label === null) { return v; } return label; }); }, getDropdownDOMNode: function getDropdownDOMNode() { return _react2['default'].findDOMNode(this.dropdownInstance); }, getDropdownContainer: function getDropdownContainer() { if (!this.dropdownContainer) { this.dropdownContainer = document.createElement('div'); document.body.appendChild(this.dropdownContainer); } return this.dropdownContainer; }, getSearchPlaceholderElement: function getSearchPlaceholderElement(hidden) { var props = this.props; if (props.searchPlaceholder) { return _react2['default'].createElement( 'span', { style: { display: hidden ? 'none' : 'block' }, onClick: this.onPlaceholderClick, className: props.prefixCls + '-search__field__placeholder' }, props.searchPlaceholder ); } return null; }, getInputElement: function getInputElement() { var props = this.props; return _react2['default'].createElement( 'span', { className: props.prefixCls + '-search__field__wrap' }, _react2['default'].createElement('input', { ref: this.saveInputRef, onChange: this.onInputChange, onKeyDown: this.onInputKeyDown, value: this.state.inputValue, disabled: props.disabled, className: props.prefixCls + '-search__field', role: 'textbox' }), (0, _util.isMultipleOrTags)(props) ? null : this.getSearchPlaceholderElement(!!this.state.inputValue) ); }, getDropdownElement: function getDropdownElement() { var state = this.state; var props = this.props; return _react2['default'].createElement( _Dropdown2['default'], { key: 'dropdown', transitionName: this.getDropdownTransitionName(), visible: state.open, getAlignTarget: this.getDOMNode, onDropdownFocus: this.onFocus, onDropdownBlur: this.onBlur, filterOption: props.filterOption, optionFilterProp: props.optionFilterProp, optionLabelProp: props.optionLabelProp, inputValue: state.inputValue, inputElement: this.getInputElement(), ref: this.saveDropdownRef, tags: props.tags, notFoundContent: props.notFoundContent, onMenuDeselect: this.onMenuDeselect, onMenuSelect: this.onMenuSelect, value: state.value, isMultipleOrTags: (0, _util.isMultipleOrTags)(props), prefixCls: props.prefixCls, isMultipleOrTagsOrCombobox: (0, _util.isMultipleOrTagsOrCombobox)(props), showSearch: props.showSearch, className: props.dropdownClassName, dropdownMenuStyle: props.dropdownMenuStyle, dropdownStyle: props.dropdownStyle }, props.children ); }, getDropdownTransitionName: function getDropdownTransitionName() { var props = this.props; var transitionName = props.transitionName; if (!transitionName && props.animation) { transitionName = props.prefixCls + '-dropdown-' + props.animation; } return transitionName; }, getInputDOMNode: function getInputDOMNode() { return _react2['default'].findDOMNode(this.inputInstance); }, renderTopControlNode: function renderTopControlNode() { var _this4 = this; var value = this.state.value; var label = this.state.label; var props = this.props; var prefixCls = props.prefixCls; var allowClear = props.allowClear; var clear = _react2['default'].createElement('span', { key: 'clear', className: prefixCls + '-selection__clear', onClick: this.onClearSelection }); // single and not combobox, input is inside dropdown if ((0, _util.isSingleMode)(props)) { var placeholder = _react2['default'].createElement( 'span', { key: 'placeholder', className: prefixCls + '-selection__placeholder' }, props.placeholder ); var innerNode = placeholder; if (this.state.label[0]) { innerNode = _react2['default'].createElement( 'span', { key: 'value' }, this.state.label[0] ); } return _react2['default'].createElement( 'span', { className: prefixCls + '-selection__rendered' }, [innerNode, allowClear ? clear : null] ); } var selectedValueNodes = undefined; if ((0, _util.isMultipleOrTags)(props)) { selectedValueNodes = value.map(function (v, index) { var content = label[index]; var title = content; var maxTagTextLength = props.maxTagTextLength; if (maxTagTextLength && typeof content === 'string' && content.length > maxTagTextLength) { content = content.slice(0, maxTagTextLength) + '...'; } return _react2['default'].createElement( 'li', { className: prefixCls + '-selection__choice', key: v, title: title }, _react2['default'].createElement( 'span', { className: prefixCls + '-selection__choice__content' }, content ), _react2['default'].createElement('span', { className: prefixCls + '-selection__choice__remove', onClick: _this4.removeSelected.bind(_this4, v) }) ); }); } return _react2['default'].createElement( 'ul', { className: prefixCls + '-selection__rendered' }, selectedValueNodes, allowClear && !(0, _util.isMultipleOrTags)(props) ? clear : null, _react2['default'].createElement( 'li', { className: prefixCls + '-search ' + prefixCls + '-search--inline' }, this.getInputElement() ) ); }, render: function render() { var _rootCls; var props = this.props; var multiple = (0, _util.isMultipleOrTags)(props); var state = this.state; var prefixCls = props.prefixCls; var ctrlNode = this.renderTopControlNode(); var extraSelectionProps = {}; if (!(0, _util.isCombobox)(props)) { extraSelectionProps = { onKeyDown: this.onKeyDown, tabIndex: 0 }; } var rootCls = (_rootCls = {}, _defineProperty(_rootCls, props.className, !!props.className), _defineProperty(_rootCls, prefixCls, 1), _defineProperty(_rootCls, prefixCls + '-open', this.state.open), _defineProperty(_rootCls, prefixCls + '-combobox', (0, _util.isCombobox)(props)), _defineProperty(_rootCls, prefixCls + '-disabled', props.disabled), _rootCls); this.haveOpened = this.haveOpened || state.open; return _react2['default'].createElement( 'span', { style: props.style, className: (0, _rcUtil.classSet)(rootCls), onFocus: this.onFocus, onBlur: this.onBlur }, _react2['default'].createElement( 'span', _extends({ ref: 'selection', key: 'selection', className: prefixCls + '-selection ' + prefixCls + '-selection--' + (multiple ? 'multiple' : 'single'), role: 'combobox', 'aria-autocomplete': 'list', onClick: this.onClick, 'aria-haspopup': 'true', 'aria-expanded': state.open }, extraSelectionProps), ctrlNode, multiple || !props.showArrow ? null : _react2['default'].createElement( 'span', { key: 'arrow', className: prefixCls + '-arrow', tabIndex: '-1', style: { outline: 'none' } }, _react2['default'].createElement('b', null) ), multiple ? this.getSearchPlaceholderElement(!!this.state.inputValue || this.state.value.length) : null ) ); }, removeSelected: function removeSelected(selectedValue) { var props = this.props; if (props.disabled) { return; } var label = this.state.label.concat(); var index = this.state.value.indexOf(selectedValue); var value = this.state.value.filter(function (v) { return v !== selectedValue; }); if (index !== -1) { label.splice(index, 1); } var canMultiple = (0, _util.isMultipleOrTags)(props); if (canMultiple) { props.onDeselect(selectedValue); } this.fireChange(value, label); }, setOpenState: function setOpenState(open) { var _this5 = this; var refs = this.refs; this.setState({ open: open }, function () { if (open || (0, _util.isMultipleOrTagsOrCombobox)(_this5.props)) { if (_this5.getInputDOMNode()) { _this5.getInputDOMNode().focus(); } } else if (refs.selection) { _react2['default'].findDOMNode(refs.selection).focus(); } }); }, openIfHasChildren: function openIfHasChildren() { var props = this.props; if (_react2['default'].Children.count(props.children) || (0, _util.isSingleMode)(props)) { this.setOpenState(true); } }, fireChange: function fireChange(value, label) { var props = this.props; if (!('value' in props)) { this.setState({ value: value, label: label }); } props.onChange(this.getVLForOnChange(value), this.getVLForOnChange(label)); } }); exports['default'] = Select; module.exports = exports['default']; /***/ }, /* 220 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var OptGroup = (function (_React$Component) { _inherits(OptGroup, _React$Component); function OptGroup() { _classCallCheck(this, OptGroup); _get(Object.getPrototypeOf(OptGroup.prototype), 'constructor', this).apply(this, arguments); } return OptGroup; })(_react2['default'].Component); exports['default'] = OptGroup; module.exports = exports['default']; /***/ }, /* 221 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _util = __webpack_require__(222); var _rcMenu = __webpack_require__(223); var _OptGroup = __webpack_require__(220); var _OptGroup2 = _interopRequireDefault(_OptGroup); var _rcUtil = __webpack_require__(77); var _DropdownPanel = __webpack_require__(237); var _DropdownPanel2 = _interopRequireDefault(_DropdownPanel); var _rcAlign = __webpack_require__(238); var _rcAlign2 = _interopRequireDefault(_rcAlign); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var SelectDropdown = (function (_React$Component) { _inherits(SelectDropdown, _React$Component); function SelectDropdown() { _classCallCheck(this, SelectDropdown); _get(Object.getPrototypeOf(SelectDropdown.prototype), 'constructor', this).apply(this, arguments); } _createClass(SelectDropdown, [{ key: 'shouldComponentUpdate', value: function shouldComponentUpdate(nextProps) { return this.props.visible || nextProps.visible; } }, { key: 'getDropdownPrefixCls', value: function getDropdownPrefixCls() { return this.props.prefixCls + '-dropdown'; } }, { key: 'getMenuComponent', value: function getMenuComponent() { return this.refs.panel.refs.menu; } }, { key: 'renderFilterOptionsFromChildren', value: function renderFilterOptionsFromChildren(children, showNotFound) { var _this = this; var sel = []; var props = this.props; var inputValue = props.inputValue; var childrenKeys = []; var tags = props.tags; _react2['default'].Children.forEach(children, function (child) { if (child.type === _OptGroup2['default']) { var innerItems = _this.renderFilterOptionsFromChildren(child.props.children, false); if (innerItems.length) { var label = child.props.label; var key = child.key; if (!key && typeof label === 'string') { key = label; } else if (!label && key) { label = key; } sel.push(_react2['default'].createElement( _rcMenu.ItemGroup, { key: key, title: label }, innerItems )); } return; } var childValue = (0, _util.getValuePropValue)(child); if (_this.filterOption(inputValue, child)) { sel.push(_react2['default'].createElement(_rcMenu.Item, _extends({ value: childValue, key: childValue }, child.props))); } if (tags && !child.props.disabled) { childrenKeys.push(childValue); } }); if (tags) { // tags value must be string var value = props.value; value = value.filter(function (v) { return childrenKeys.indexOf(v) === -1 && (!inputValue || v.indexOf(inputValue) > -1); }); sel = sel.concat(value.map(function (v) { return _react2['default'].createElement( _rcMenu.Item, { value: v, key: v }, v ); })); if (inputValue) { var notFindInputItem = sel.every(function (s) { return (0, _util.getValuePropValue)(s) !== inputValue; }); if (notFindInputItem) { sel.unshift(_react2['default'].createElement( _rcMenu.Item, { value: inputValue, key: inputValue }, inputValue )); } } } if (!sel.length && showNotFound && props.notFoundContent) { sel = [_react2['default'].createElement( _rcMenu.Item, { disabled: true, value: 'NOT_FOUND', key: 'NOT_FOUND' }, props.notFoundContent )]; } return sel; } }, { key: 'renderFilterOptions', value: function renderFilterOptions() { return this.renderFilterOptionsFromChildren(this.props.children, true); } }, { key: 'render', value: function render() { var _className; var props = this.props; var prefixCls = props.prefixCls; var dropdownPrefixCls = this.getDropdownPrefixCls(); var menuItems = this.renderFilterOptions(); var visible = props.visible; var search = props.isMultipleOrTagsOrCombobox || !props.showSearch ? null : _react2['default'].createElement( 'span', { className: prefixCls + '-search ' + prefixCls + '-search--dropdown' }, props.inputElement ); if (!search && !menuItems.length) { visible = false; } var className = (_className = {}, _defineProperty(_className, dropdownPrefixCls, 1), _defineProperty(_className, dropdownPrefixCls + '--below', 1), _defineProperty(_className, dropdownPrefixCls + '-hidden', !visible), _defineProperty(_className, props.className, !!props.className), _defineProperty(_className, dropdownPrefixCls + '--' + (props.isMultipleOrTags ? 'multiple' : 'single'), 1), _className); // single and not combobox, input is inside dropdown return _react2['default'].createElement( _rcAnimate2['default'], { component: '', exclusive: true, transitionAppear: true, showProp: 'selectOpen', transitionName: props.transitionName }, _react2['default'].createElement( _rcAlign2['default'], { target: props.getAlignTarget, key: 'dropdown', selectOpen: visible, disabled: !visible, align: { points: ['tl', 'bl'], offset: [0, 4] } }, _react2['default'].createElement( 'div', { key: 'dropdown', onFocus: props.onDropdownFocus, onBlur: props.onDropdownBlur, style: props.dropdownStyle, className: (0, _rcUtil.classSet)(className), tabIndex: '-1' }, _react2['default'].createElement(_DropdownPanel2['default'], _extends({ ref: 'panel' }, props, { menuItems: menuItems, visible: visible, search: search })) ) ) ); } }, { key: 'filterOption', value: function filterOption(input, child) { if (!input) { return true; } var filterOption = this.props.filterOption; if (!filterOption) { return true; } if (child.props.disabled) { return false; } return filterOption.call(this, input, child); } }]); return SelectDropdown; })(_react2['default'].Component); SelectDropdown.propTypes = { filterOption: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.bool, _react2['default'].PropTypes.func]), visible: _react2['default'].PropTypes.bool, prefixCls: _react2['default'].PropTypes.string, children: _react2['default'].PropTypes.any }; exports['default'] = SelectDropdown; module.exports = exports['default']; /***/ }, /* 222 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports.getValuePropValue = getValuePropValue; exports.getPropValue = getPropValue; exports.isCombobox = isCombobox; exports.isMultipleOrTags = isMultipleOrTags; exports.isMultipleOrTagsOrCombobox = isMultipleOrTagsOrCombobox; exports.isSingleMode = isSingleMode; exports.toArray = toArray; exports.getSelectKeys = getSelectKeys; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rcMenu = __webpack_require__(223); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); function getValuePropValue(c) { var props = c.props; if ('value' in props) { return props.value; } if (c.key) { return c.key; } throw new Error('no key or value for ' + c); } function getPropValue(c, prop) { if (prop === 'value') { return getValuePropValue(c); } return c.props[prop]; } function isCombobox(props) { return props.combobox; } function isMultipleOrTags(props) { return props.multiple || props.tags; } function isMultipleOrTagsOrCombobox(props) { return isMultipleOrTags(props) || isCombobox(props); } function isSingleMode(props) { return !isMultipleOrTagsOrCombobox(props); } function toArray(value) { var ret = value; if (value === undefined) { ret = []; } else if (!Array.isArray(value)) { ret = [value]; } return ret; } function getSelectKeys(menuItems, value) { if (value === null || value === undefined) { return []; } var selectedKeys = []; _react2['default'].Children.forEach(menuItems, function (item) { if (item.type === _rcMenu.ItemGroup) { selectedKeys = selectedKeys.concat(getSelectKeys(item.props.children, value)); } else { var itemValue = getValuePropValue(item); var itemKey = item.key; if (value.indexOf(itemValue) !== -1 && itemKey) { selectedKeys.push(itemKey); } } }); return selectedKeys; } /***/ }, /* 223 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Menu = __webpack_require__(224); var _Menu2 = _interopRequireDefault(_Menu); var _SubMenu = __webpack_require__(231); var _SubMenu2 = _interopRequireDefault(_SubMenu); var _MenuItem = __webpack_require__(234); var _MenuItem2 = _interopRequireDefault(_MenuItem); var _MenuItemGroup = __webpack_require__(235); var _MenuItemGroup2 = _interopRequireDefault(_MenuItemGroup); var _Divider = __webpack_require__(236); var _Divider2 = _interopRequireDefault(_Divider); _Menu2['default'].SubMenu = _SubMenu2['default']; _Menu2['default'].Item = _MenuItem2['default']; _Menu2['default'].ItemGroup = _MenuItemGroup2['default']; _Menu2['default'].Divider = _Divider2['default']; exports['default'] = _Menu2['default']; module.exports = exports['default']; /***/ }, /* 224 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _MenuMixin = __webpack_require__(225); var _MenuMixin2 = _interopRequireDefault(_MenuMixin); var _objectAssign = __webpack_require__(229); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _util = __webpack_require__(230); var Menu = _react2['default'].createClass({ displayName: 'Menu', propTypes: { openSubMenuOnMouseEnter: _react2['default'].PropTypes.bool, closeSubMenuOnMouseLeave: _react2['default'].PropTypes.bool, selectedKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), defaultSelectedKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), defaultOpenKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), openKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), mode: _react2['default'].PropTypes.string, onClick: _react2['default'].PropTypes.func, onSelect: _react2['default'].PropTypes.func, onDeselect: _react2['default'].PropTypes.func, onDestroy: _react2['default'].PropTypes.func, openTransitionName: _react2['default'].PropTypes.string, openAnimation: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.string, _react2['default'].PropTypes.object]), level: _react2['default'].PropTypes.number, eventKey: _react2['default'].PropTypes.string, selectable: _react2['default'].PropTypes.bool }, getDefaultProps: function getDefaultProps() { return { openSubMenuOnMouseEnter: true, closeSubMenuOnMouseLeave: true, selectable: true, onClick: _util.noop, onSelect: _util.noop, onOpen: _util.noop, onClose: _util.noop, onDeselect: _util.noop, defaultSelectedKeys: [], defaultOpenKeys: [] }; }, mixins: [_MenuMixin2['default']], getInitialState: function getInitialState() { var props = this.props; var selectedKeys = props.defaultSelectedKeys; var openKeys = props.defaultOpenKeys; if ('selectedKeys' in props) { selectedKeys = props.selectedKeys || []; } if ('openKeys' in props) { openKeys = props.openKeys || []; } return { selectedKeys: selectedKeys, openKeys: openKeys }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var props = {}; if ('selectedKeys' in nextProps) { props.selectedKeys = nextProps.selectedKeys; } if ('openKeys' in nextProps) { props.openKeys = nextProps.openKeys; } this.setState(props); }, onDestroy: function onDestroy(key) { var state = this.state; var props = this.props; var selectedKeys = state.selectedKeys; var openKeys = state.openKeys; var index = selectedKeys.indexOf(key); if (!('selectedKeys' in props) && index !== -1) { selectedKeys.splice(index, 1); } index = openKeys.indexOf(key); if (!('openKeys' in props) && index !== -1) { openKeys.splice(index, 1); } }, onItemHover: function onItemHover(e) { var _this = this; var item = e.item; // special for top sub menu if (this.props.mode !== 'inline' && !this.props.closeSubMenuOnMouseLeave && item.isSubMenu) { (function () { var activeKey = _this.state.activeKey; var activeItem = _this.instanceArray.filter(function (c) { return c.props.eventKey === activeKey; })[0]; if (activeItem && activeItem.props.open) { _this.onOpenChange({ key: item.props.eventKey, item: e.item, open: true }); } })(); } this.onCommonItemHover(e); }, onSelect: function onSelect(selectInfo) { var props = this.props; if (props.selectable) { // root menu var selectedKeys = this.state.selectedKeys; var selectedKey = selectInfo.key; if (props.multiple) { selectedKeys = selectedKeys.concat([selectedKey]); } else { selectedKeys = [selectedKey]; } if (!('selectedKeys' in props)) { this.setState({ selectedKeys: selectedKeys }); } props.onSelect((0, _objectAssign2['default'])({}, selectInfo, { selectedKeys: selectedKeys })); } }, onClick: function onClick(e) { var props = this.props; props.onClick(e); }, onOpenChange: function onOpenChange(e) { var openKeys = this.state.openKeys; var props = this.props; var changed = true; if (e.open) { changed = openKeys.indexOf(e.key) === -1; if (changed) { openKeys = openKeys.concat(e.key); } } else { var index = openKeys.indexOf(e.key); changed = index !== -1; if (changed) { openKeys = openKeys.concat(); openKeys.splice(index, 1); } } if (changed) { if (!('openKeys' in this.props)) { // hack: batch does not update state this.state.openKeys = openKeys; this.setState({ openKeys: openKeys }); } var info = (0, _objectAssign2['default'])({ openKeys: openKeys }, e); if (e.open) { props.onOpen(info); } else { props.onClose(info); } } }, onDeselect: function onDeselect(selectInfo) { var props = this.props; if (props.selectable) { var selectedKeys = this.state.selectedKeys.concat(); var selectedKey = selectInfo.key; var index = selectedKeys.indexOf(selectedKey); if (index !== -1) { selectedKeys.splice(index, 1); } if (!('selectedKeys' in props)) { this.setState({ selectedKeys: selectedKeys }); } props.onDeselect((0, _objectAssign2['default'])({}, selectInfo, { selectedKeys: selectedKeys })); } }, getOpenTransitionName: function getOpenTransitionName() { var props = this.props; var transitionName = props.openTransitionName; var animationName = props.openAnimation; if (!transitionName && typeof animationName === 'string') { transitionName = props.prefixCls + '-open-' + animationName; } return transitionName; }, renderMenuItem: function renderMenuItem(c, i) { var key = (0, _util.getKeyFromChildrenIndex)(c, this.props.eventKey, i); var state = this.state; var extraProps = { openKeys: state.openKeys, open: state.openKeys.indexOf(key) !== -1, selectedKeys: state.selectedKeys, selected: state.selectedKeys.indexOf(key) !== -1, openSubMenuOnMouseEnter: this.props.openSubMenuOnMouseEnter }; return this.renderCommonMenuItem(c, i, extraProps); }, render: function render() { var props = (0, _objectAssign2['default'])({}, this.props); props.className += ' ' + props.prefixCls + '-root'; return this.renderRoot(props); }, isInlineMode: function isInlineMode() { return this.props.mode === 'inline'; }, lastOpenSubMenu: function lastOpenSubMenu() { var _this2 = this; var lastOpen = []; if (this.state.openKeys.length) { lastOpen = this.instanceArray.filter(function (c) { return _this2.state.openKeys.indexOf(c.props.eventKey) !== -1; }); } return lastOpen[0]; } }); exports['default'] = Menu; module.exports = exports['default']; /***/ }, /* 225 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _domScrollIntoView = __webpack_require__(226); var _domScrollIntoView2 = _interopRequireDefault(_domScrollIntoView); var _objectAssign = __webpack_require__(229); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _util = __webpack_require__(230); function getActiveKey(props) { var activeKey = props.activeKey; var children = props.children; var eventKey = props.eventKey; if (activeKey) { var found = undefined; _react2['default'].Children.forEach(children, function (c, i) { if (!c.props.disabled && activeKey === (0, _util.getKeyFromChildrenIndex)(c, eventKey, i)) { found = true; } }); if (found) { return activeKey; } } activeKey = null; if (props.defaultActiveFirst) { _react2['default'].Children.forEach(children, function (c, i) { if (!activeKey && !c.props.disabled) { activeKey = (0, _util.getKeyFromChildrenIndex)(c, eventKey, i); } }); return activeKey; } return activeKey; } function saveRef(name, c) { if (c) { this.instanceArray.push(c); } } var MenuMixin = { propTypes: { focusable: _react2['default'].PropTypes.bool, multiple: _react2['default'].PropTypes.bool, style: _react2['default'].PropTypes.object, defaultActiveFirst: _react2['default'].PropTypes.bool, visible: _react2['default'].PropTypes.bool, activeKey: _react2['default'].PropTypes.string, selectedKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), defaultSelectedKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), defaultOpenKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), openKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string) }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-menu', className: '', mode: 'vertical', level: 1, inlineIndent: 24, visible: true, focusable: true, style: {} }; }, getInitialState: function getInitialState() { var props = this.props; return { activeKey: getActiveKey(props) }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var props = {}; if ('activeKey' in nextProps) { props.activeKey = getActiveKey(nextProps); } this.setState(props); }, shouldComponentUpdate: function shouldComponentUpdate(nextProps) { return this.props.visible || nextProps.visible; }, componentWillMount: function componentWillMount() { this.instanceArray = []; }, // all keyboard events callbacks run from here at first onKeyDown: function onKeyDown(e) { var _this = this; var keyCode = e.keyCode; var handled = undefined; this.instanceArray.forEach(function (obj) { if (obj.props.active) { handled = obj.onKeyDown(e); } }); if (handled) { return 1; } var activeItem = undefined; switch (keyCode) { case _rcUtil.KeyCode.UP: activeItem = this.step(-1); break; case _rcUtil.KeyCode.DOWN: activeItem = this.step(1); break; default: } if (activeItem) { e.preventDefault(); this.setState({ activeKey: activeItem.props.eventKey }, function () { (0, _domScrollIntoView2['default'])(_react2['default'].findDOMNode(activeItem), _react2['default'].findDOMNode(_this), { onlyScrollIfNeeded: true }); }); return 1; } }, onCommonItemHover: function onCommonItemHover(e) { var mode = this.props.mode; var key = e.key; var hover = e.hover; var trigger = e.trigger; var activeKey = this.state.activeKey; if (!trigger || hover || this.props.closeSubMenuOnMouseLeave || !e.item.isSubMenu || mode === 'inline') { this.setState({ activeKey: hover ? key : null }); } else {} // keep active for sub menu for click active // empty // clear last open status if (hover && mode !== 'inline') { var activeItem = this.instanceArray.filter(function (c) { return c.props.eventKey === activeKey; })[0]; if (activeItem && activeItem.isSubMenu && activeItem.props.eventKey !== key) { this.onOpenChange({ item: activeItem, key: activeItem.props.eventKey, open: false }); } } }, renderCommonMenuItem: function renderCommonMenuItem(child, i, extraProps) { var state = this.state; var props = this.props; var key = (0, _util.getKeyFromChildrenIndex)(child, props.eventKey, i); var childProps = child.props; var newChildProps = (0, _objectAssign2['default'])({ mode: props.mode, level: props.level, inlineIndent: props.inlineIndent, renderMenuItem: this.renderMenuItem, rootPrefixCls: props.prefixCls, ref: (0, _rcUtil.createChainedFunction)(child.ref, saveRef.bind(this, key)), eventKey: key, closeSubMenuOnMouseLeave: props.closeSubMenuOnMouseLeave, onItemHover: this.onItemHover, active: !childProps.disabled && key === state.activeKey, multiple: props.multiple, onClick: this.onClick, openTransitionName: this.getOpenTransitionName(), openAnimation: props.openAnimation, onOpenChange: this.onOpenChange, onDeselect: this.onDeselect, onDestroy: this.onDestroy, onSelect: this.onSelect }, extraProps); if (props.mode === 'inline') { newChildProps.closeSubMenuOnMouseLeave = newChildProps.openSubMenuOnMouseEnter = false; } return _react2['default'].cloneElement(child, newChildProps); }, renderRoot: function renderRoot(props) { var _classes; this.instanceArray = []; var classes = (_classes = {}, _defineProperty(_classes, props.prefixCls, 1), _defineProperty(_classes, props.prefixCls + '-' + props.mode, 1), _defineProperty(_classes, props.className, !!props.className), _classes); var domProps = { className: (0, _rcUtil.classSet)(classes), role: 'menu', 'aria-activedescendant': '' }; if (props.id) { domProps.id = props.id; } if (props.focusable) { domProps.tabIndex = '0'; domProps.onKeyDown = this.onKeyDown; } return _react2['default'].createElement( 'ul', _extends({ style: props.style, 'data-visible': props.visible }, domProps), _react2['default'].Children.map(props.children, this.renderMenuItem) ); }, step: function step(direction) { var children = this.instanceArray; var activeKey = this.state.activeKey; var len = children.length; if (direction < 0) { children = children.concat().reverse(); } // find current activeIndex var activeIndex = -1; children.every(function (c, ci) { if (c.props.eventKey === activeKey) { activeIndex = ci; return false; } return true; }); var start = (activeIndex + 1) % len; var i = start; for (;;) { var child = children[i]; if (child.props.disabled) { i = (i + 1 + len) % len; // complete a loop if (i === start) { return null; } } else { return child; } } } }; exports['default'] = MenuMixin; module.exports = exports['default']; /***/ }, /* 226 */ /***/ function(module, exports, __webpack_require__) { module.exports = __webpack_require__(227); /***/ }, /* 227 */ /***/ function(module, exports, __webpack_require__) { var util = __webpack_require__(228); function scrollIntoView(elem, container, config) { config = config || {}; // document 归一化到 window if (container.nodeType === 9) { container = util.getWindow(container); } var allowHorizontalScroll = config.allowHorizontalScroll; var onlyScrollIfNeeded = config.onlyScrollIfNeeded; var alignWithTop = config.alignWithTop; var alignWithLeft = config.alignWithLeft; allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll; var isWin = util.isWindow(container); var elemOffset = util.offset(elem); var eh = util.outerHeight(elem); var ew = util.outerWidth(elem); var containerOffset, ch, cw, containerScroll, diffTop, diffBottom, win, winScroll, ww, wh; if (isWin) { win = container; wh = util.height(win); ww = util.width(win); winScroll = { left: util.scrollLeft(win), top: util.scrollTop(win) }; // elem 相对 container 可视视窗的距离 diffTop = { left: elemOffset.left - winScroll.left, top: elemOffset.top - winScroll.top }; diffBottom = { left: elemOffset.left + ew - (winScroll.left + ww), top: elemOffset.top + eh - (winScroll.top + wh) }; containerScroll = winScroll; } else { containerOffset = util.offset(container); ch = container.clientHeight; cw = container.clientWidth; containerScroll = { left: container.scrollLeft, top: container.scrollTop }; // elem 相对 container 可视视窗的距离 // 注意边框, offset 是边框到根节点 diffTop = { left: elemOffset.left - (containerOffset.left + (parseFloat(util.css(container, 'borderLeftWidth')) || 0)), top: elemOffset.top - (containerOffset.top + (parseFloat(util.css(container, 'borderTopWidth')) || 0)) }; diffBottom = { left: elemOffset.left + ew - (containerOffset.left + cw + (parseFloat(util.css(container, 'borderRightWidth')) || 0)), top: elemOffset.top + eh - (containerOffset.top + ch + (parseFloat(util.css(container, 'borderBottomWidth')) || 0)) }; } if (diffTop.top < 0 || diffBottom.top > 0) { // 强制向上 if (alignWithTop === true) { util.scrollTop(container, containerScroll.top + diffTop.top); } else if (alignWithTop === false) { util.scrollTop(container, containerScroll.top + diffBottom.top); } else { // 自动调整 if (diffTop.top < 0) { util.scrollTop(container, containerScroll.top + diffTop.top); } else { util.scrollTop(container, containerScroll.top + diffBottom.top); } } } else { if (!onlyScrollIfNeeded) { alignWithTop = alignWithTop === undefined ? true : !!alignWithTop; if (alignWithTop) { util.scrollTop(container, containerScroll.top + diffTop.top); } else { util.scrollTop(container, containerScroll.top + diffBottom.top); } } } if (allowHorizontalScroll) { if (diffTop.left < 0 || diffBottom.left > 0) { // 强制向上 if (alignWithLeft === true) { util.scrollLeft(container, containerScroll.left + diffTop.left); } else if (alignWithLeft === false) { util.scrollLeft(container, containerScroll.left + diffBottom.left); } else { // 自动调整 if (diffTop.left < 0) { util.scrollLeft(container, containerScroll.left + diffTop.left); } else { util.scrollLeft(container, containerScroll.left + diffBottom.left); } } } else { if (!onlyScrollIfNeeded) { alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft; if (alignWithLeft) { util.scrollLeft(container, containerScroll.left + diffTop.left); } else { util.scrollLeft(container, containerScroll.left + diffBottom.left); } } } } } module.exports = scrollIntoView; /***/ }, /* 228 */ /***/ function(module, exports) { var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; function getClientPosition(elem) { var box, x, y; var doc = elem.ownerDocument; var body = doc.body; var docElem = doc && doc.documentElement; // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 box = elem.getBoundingClientRect(); // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin x = box.left; y = box.top; // In IE, most of the time, 2 extra pixels are added to the top and left // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and // IE6 standards mode, this border can be overridden by setting the // document element's border to zero -- thus, we cannot rely on the // offset always being 2 pixels. // In quirks mode, the offset can be determined by querying the body's // clientLeft/clientTop, but in standards mode, it is found by querying // the document element's clientLeft/clientTop. Since we already called // getClientBoundingRect we have already forced a reflow, so it is not // too expensive just to query them all. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 // 窗口边框标准是设 documentElement ,quirks 时设置 body // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 // 标准 ie 下 docElem.clientTop 就是 border-top // ie7 html 即窗口边框改变不了。永远为 2 // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 x -= docElem.clientLeft || body.clientLeft || 0; y -= docElem.clientTop || body.clientTop || 0; return {left: x, top: y}; } function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; //ie6,7,8 standard mode ret = d.documentElement[method]; if (typeof ret !== 'number') { //quirks mode ret = d.body[method]; } } return ret; } function getScrollLeft(w) { return getScroll(w); } function getScrollTop(w) { return getScroll(w, true); } function getOffset(el) { var pos = getClientPosition(el); var doc = el.ownerDocument; var w = doc.defaultView || doc.parentWindow; pos.left += getScrollLeft(w); pos.top += getScrollTop(w); return pos; } function _getComputedStyle(elem, name, computedStyle) { var val = ''; var d = elem.ownerDocument; // https://github.com/kissyteam/kissy/issues/61 if ((computedStyle = (computedStyle || d.defaultView.getComputedStyle(elem, null)))) { val = computedStyle.getPropertyValue(name) || computedStyle[name]; } return val; } var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); var RE_POS = /^(top|right|bottom|left)$/, CURRENT_STYLE = 'currentStyle', RUNTIME_STYLE = 'runtimeStyle', LEFT = 'left', PX = 'px'; function _getComputedStyleIE(elem, name) { // currentStyle maybe null // http://msdn.microsoft.com/en-us/library/ms535231.aspx var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 // 在 ie 下不对,需要直接用 offset 方式 // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // If we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels // exclude left right for relativity if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { // Remember the original values var style = elem.style, left = style[LEFT], rsLeft = elem[RUNTIME_STYLE][LEFT]; // prevent flashing of content elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; // Put in the new values to get a computed value out style[LEFT] = name === 'fontSize' ? '1em' : (ret || 0); ret = style.pixelLeft + PX; // Revert the changed values style[LEFT] = left; elem[RUNTIME_STYLE][LEFT] = rsLeft; } return ret === '' ? 'auto' : ret; } var getComputedStyleX; if (typeof window !== 'undefined') { getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; } // 设置 elem 相对 elem.ownerDocument 的坐标 function setOffset(elem, offset) { // set position first, in-case top/left are set even on static elem if (css(elem, 'position') === 'static') { elem.style.position = 'relative'; } var old = getOffset(elem), ret = {}, current, key; for (key in offset) { current = parseFloat(css(elem, key)) || 0; ret[key] = current + offset[key] - old[key]; } css(elem, ret); } function each(arr, fn) { for (var i = 0; i < arr.length; i++) { fn(arr[i]); } } function isBorderBoxFn(elem) { return getComputedStyleX(elem, 'boxSizing') === 'border-box'; } var BOX_MODELS = ['margin', 'border', 'padding'], CONTENT_INDEX = -1, PADDING_INDEX = 2, BORDER_INDEX = 1, MARGIN_INDEX = 0; function swap(elem, options, callback) { var old = {}, style = elem.style, name; // Remember the old values, and insert the new ones for (name in options) { old[name] = style[name]; style[name] = options[name]; } callback.call(elem); // Revert the old values for (name in options) { style[name] = old[name]; } } function getPBMWidth(elem, props, which) { var value = 0, prop, j, i; for (j = 0; j < props.length; j++) { prop = props[j]; if (prop) { for (i = 0; i < which.length; i++) { var cssProp; if (prop === 'border') { cssProp = prop + which[i] + 'Width'; } else { cssProp = prop + which[i]; } value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; } } } return value; } /** * A crude way of determining if an object is a window * @member util */ function isWindow(obj) { // must use == for ie8 /*jshint eqeqeq:false*/ return obj != null && obj == obj.window; } var domUtils = {}; each(['Width', 'Height'], function (name) { domUtils['doc' + name] = function (refWin) { var d = refWin.document; return Math.max( //firefox chrome documentElement.scrollHeight< body.scrollHeight //ie standard mode : documentElement.scrollHeight> body.scrollHeight d.documentElement['scroll' + name], //quirks : documentElement.scrollHeight 最大等于可视窗口多一点? d.body['scroll' + name], domUtils['viewport' + name](d)); }; domUtils['viewport' + name] = function (win) { // pc browser includes scrollbar in window.innerWidth var prop = 'client' + name, doc = win.document, body = doc.body, documentElement = doc.documentElement, documentElementProp = documentElement[prop]; // 标准模式取 documentElement // backcompat 取 body return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp; }; }); /* 得到元素的大小信息 @param elem @param name @param {String} [extra] 'padding' : (css width) + padding 'border' : (css width) + padding + border 'margin' : (css width) + padding + border + margin */ function getWH(elem, name, extra) { if (isWindow(elem)) { return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); } else if (elem.nodeType === 9) { return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); } var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'], borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem, computedStyle); var cssBoxValue = 0; if (borderBoxValue == null || borderBoxValue <= 0) { borderBoxValue = undefined; // Fall back to computed then un computed css if necessary cssBoxValue = getComputedStyleX(elem, name); if (cssBoxValue == null || (Number(cssBoxValue)) < 0) { cssBoxValue = elem.style[name] || 0; } // Normalize '', auto, and prepare for extra cssBoxValue = parseFloat(cssBoxValue) || 0; } if (extra === undefined) { extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; } var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; var val = borderBoxValue || cssBoxValue; if (extra === CONTENT_INDEX) { if (borderBoxValueOrIsBorderBox) { return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle); } else { return cssBoxValue; } } else if (borderBoxValueOrIsBorderBox) { return val + (extra === BORDER_INDEX ? 0 : (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle))); } else { return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle); } } var cssShow = {position: 'absolute', visibility: 'hidden', display: 'block'}; // fix #119 : https://github.com/kissyteam/kissy/issues/119 function getWHIgnoreDisplay(elem) { var val, args = arguments; // in case elem is window // elem.offsetWidth === undefined if (elem.offsetWidth !== 0) { val = getWH.apply(undefined, args); } else { swap(elem, cssShow, function () { val = getWH.apply(undefined, args); }); } return val; } each(['width', 'height'], function (name) { var first = name.charAt(0).toUpperCase() + name.slice(1); domUtils['outer' + first] = function (el, includeMargin) { return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); }; var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; domUtils[name] = function (elem, val) { if (val !== undefined) { if (elem) { var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem); if (isBorderBox) { val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); } return css(elem, name, val); } return; } return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); }; }); function css(el, name, value) { if (typeof name === 'object') { for (var i in name) { css(el, i, name[i]); } return; } if (typeof value !== 'undefined') { if (typeof value === 'number') { value = value + 'px'; } el.style[name] = value; } else { return getComputedStyleX(el, name); } } function mix(to, from) { for (var i in from) { to[i] = from[i]; } return to; } var utils = module.exports = { getWindow: function (node) { var doc = node.ownerDocument || node; return doc.defaultView || doc.parentWindow; }, offset: function (el, value) { if (typeof value !== 'undefined') { setOffset(el, value); } else { return getOffset(el); } }, isWindow: isWindow, each: each, css: css, clone: function (obj) { var ret = {}; for (var i in obj) { ret[i] = obj[i]; } var overflow = obj.overflow; if (overflow) { for (i in obj) { ret.overflow[i] = obj.overflow[i]; } } return ret; }, mix: mix, scrollLeft: function (w, v) { if (isWindow(w)) { if (v === undefined) { return getScrollLeft(w); } else { window.scrollTo(v, getScrollTop(w)); } } else { if (v === undefined) { return w.scrollLeft; } else { w.scrollLeft = v; } } }, scrollTop: function (w, v) { if (isWindow(w)) { if (v === undefined) { return getScrollTop(w); } else { window.scrollTo(getScrollLeft(w), v); } } else { if (v === undefined) { return w.scrollTop; } else { w.scrollTop = v; } } }, merge: function () { var ret = {}; for (var i = 0; i < arguments.length; i++) { utils.mix(ret, arguments[i]); } return ret; }, viewportWidth: 0, viewportHeight: 0 }; mix(utils, domUtils); /***/ }, /* 229 */ /***/ function(module, exports) { 'use strict'; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function ToObject(val) { if (val == null) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function ownEnumerableKeys(obj) { var keys = Object.getOwnPropertyNames(obj); if (Object.getOwnPropertySymbols) { keys = keys.concat(Object.getOwnPropertySymbols(obj)); } return keys.filter(function (key) { return propIsEnumerable.call(obj, key); }); } module.exports = Object.assign || function (target, source) { var from; var keys; var to = ToObject(target); for (var s = 1; s < arguments.length; s++) { from = arguments[s]; keys = ownEnumerableKeys(Object(from)); for (var i = 0; i < keys.length; i++) { to[keys[i]] = from[keys[i]]; } } return to; }; /***/ }, /* 230 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var now = Date.now(); exports['default'] = { noop: function noop() {}, getKeyFromChildrenIndex: function getKeyFromChildrenIndex(child, menuEventKey, index) { var prefix = menuEventKey || ''; return child.key || prefix + 'item_' + now + '_' + index; } }; module.exports = exports['default']; /***/ }, /* 231 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _SubPopupMenu = __webpack_require__(232); var _SubPopupMenu2 = _interopRequireDefault(_SubPopupMenu); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _objectAssign = __webpack_require__(229); var _objectAssign2 = _interopRequireDefault(_objectAssign); var SubMenu = _react2['default'].createClass({ displayName: 'SubMenu', propTypes: { title: _react2['default'].PropTypes.node, onClick: _react2['default'].PropTypes.func, onOpenChange: _react2['default'].PropTypes.func, rootPrefixCls: _react2['default'].PropTypes.string, eventKey: _react2['default'].PropTypes.string, multiple: _react2['default'].PropTypes.bool, active: _react2['default'].PropTypes.bool, open: _react2['default'].PropTypes.bool, onSelect: _react2['default'].PropTypes.func, closeSubMenuOnMouseLeave: _react2['default'].PropTypes.bool, openSubMenuOnMouseEnter: _react2['default'].PropTypes.bool, onDeselect: _react2['default'].PropTypes.func, onDestroy: _react2['default'].PropTypes.func, onItemHover: _react2['default'].PropTypes.func }, mixins: [__webpack_require__(233)], getInitialState: function getInitialState() { this.isSubMenu = 1; return { defaultActiveFirst: false }; }, getDefaultProps: function getDefaultProps() { return { onMouseEnter: function onMouseEnter() {}, title: '' }; }, componentWillUnmount: function componentWillUnmount() { var props = this.props; if (props.onDestroy) { props.onDestroy(props.eventKey); } }, onDestroy: function onDestroy(key) { this.props.onDestroy(key); }, onKeyDown: function onKeyDown(e) { var keyCode = e.keyCode; var menu = this.menuInstance; if (keyCode === _rcUtil.KeyCode.ENTER) { this.onClick(e); this.setState({ defaultActiveFirst: true }); return true; } if (keyCode === _rcUtil.KeyCode.RIGHT) { if (this.props.open) { menu.onKeyDown(e); } else { this.triggerOpenChange(true); this.setState({ defaultActiveFirst: true }); } return true; } if (keyCode === _rcUtil.KeyCode.LEFT) { var handled = undefined; if (this.props.open) { handled = menu.onKeyDown(e); } else { return undefined; } if (!handled) { this.triggerOpenChange(false); handled = true; } return handled; } if (this.props.open && (keyCode === _rcUtil.KeyCode.UP || keyCode === _rcUtil.KeyCode.DOWN)) { return menu.onKeyDown(e); } }, onSubTreeMouseEnter: function onSubTreeMouseEnter() { if (this.leaveTimer) { clearTimeout(this.leaveTimer); this.leaveTimer = null; } }, onOpenChange: function onOpenChange(e) { this.props.onOpenChange(e); }, onMouseEnter: function onMouseEnter() { if (this.leaveTimer) { clearTimeout(this.leaveTimer); this.leaveTimer = null; } var props = this.props; props.onItemHover({ key: this.props.eventKey, item: this, hover: true, trigger: 'mouseenter' }); if (props.openSubMenuOnMouseEnter) { this.triggerOpenChange(true); } this.setState({ defaultActiveFirst: false }); }, onMouseLeave: function onMouseLeave() { var _this = this; // prevent popup menu and submenu gap this.leaveTimer = setTimeout(function () { // leave whole sub tree // still active if (_this.isMounted() && _this.props.active) { _this.props.onItemHover({ key: _this.props.eventKey, item: _this, hover: false, trigger: 'mouseleave' }); } if (_this.isMounted() && _this.props.open) { if (_this.props.closeSubMenuOnMouseLeave) { _this.triggerOpenChange(false); } } }, 100); }, onClick: function onClick() { if (this.props.openSubMenuOnMouseEnter) { return; } this.triggerOpenChange(!this.props.open, 'click'); this.setState({ defaultActiveFirst: false }); }, onSubMenuClick: function onSubMenuClick(info) { this.props.onClick(this.addKeyPath(info)); }, onSelect: function onSelect(info) { this.props.onSelect(info); }, onDeselect: function onDeselect(info) { this.props.onDeselect(info); }, getPrefixCls: function getPrefixCls() { return this.props.rootPrefixCls + '-submenu'; }, getActiveClassName: function getActiveClassName() { return this.getPrefixCls() + '-active'; }, getDisabledClassName: function getDisabledClassName() { return this.getPrefixCls() + '-disabled'; }, getOpenClassName: function getOpenClassName() { return this.props.rootPrefixCls + '-submenu-open'; }, renderChildren: function renderChildren(children) { var props = this.props; var baseProps = { mode: props.mode === 'horizontal' ? 'vertical' : props.mode, visible: props.open, level: props.level + 1, inlineIndent: props.inlineIndent, focusable: false, onClick: this.onSubMenuClick, onSelect: this.onSelect, onDeselect: this.onDeselect, onDestroy: this.onDestroy, selectedKeys: props.selectedKeys, eventKey: props.eventKey + '-menu-', openKeys: props.openKeys, openTransitionName: props.openTransitionName, openAnimation: props.openAnimation, onOpenChange: this.onOpenChange, closeSubMenuOnMouseLeave: props.closeSubMenuOnMouseLeave, defaultActiveFirst: this.state.defaultActiveFirst, multiple: props.multiple, prefixCls: props.rootPrefixCls, id: this._menuId, ref: this.saveMenuInstance }; return _react2['default'].createElement( _SubPopupMenu2['default'], baseProps, children ); }, render: function render() { var _classes; this.haveOpen = this.haveOpen || this.props.open; var props = this.props; var prefixCls = this.getPrefixCls(); var classes = (_classes = {}, _defineProperty(_classes, props.className, !!props.className), _defineProperty(_classes, prefixCls + '-' + props.mode, 1), _classes); classes[this.getOpenClassName()] = this.props.open; classes[this.getActiveClassName()] = props.active; classes[this.getDisabledClassName()] = props.disabled; this._menuId = this._menuId || (0, _rcUtil.guid)(); classes[prefixCls] = true; classes[prefixCls + '-' + props.mode] = 1; var clickEvents = {}; var mouseEvents = {}; var titleMouseEvents = {}; if (!props.disabled) { clickEvents = { onClick: this.onClick }; mouseEvents = { onMouseLeave: this.onMouseLeave, onMouseEnter: this.onSubTreeMouseEnter }; // only works in title, not outer li titleMouseEvents = { onMouseEnter: this.onMouseEnter }; } var style = {}; if (props.mode === 'inline') { style.paddingLeft = props.inlineIndent * props.level; } return _react2['default'].createElement( 'li', _extends({ className: (0, _rcUtil.classSet)(classes) }, mouseEvents), _react2['default'].createElement( 'div', _extends({ style: style, className: prefixCls + '-title' }, titleMouseEvents, clickEvents, { 'aria-open': props.open, 'aria-owns': this._menuId, 'aria-haspopup': 'true' }), props.title ), this.renderChildren(props.children) ); }, saveMenuInstance: function saveMenuInstance(c) { this.menuInstance = c; }, addKeyPath: function addKeyPath(info) { return (0, _objectAssign2['default'])({}, info, { keyPath: info.keyPath.concat(this.props.eventKey) }); }, triggerOpenChange: function triggerOpenChange(open, type) { var key = this.props.eventKey; this.onOpenChange({ key: key, item: this, trigger: type, open: open }); } }); exports['default'] = SubMenu; module.exports = exports['default']; /***/ }, /* 232 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _MenuMixin = __webpack_require__(225); var _MenuMixin2 = _interopRequireDefault(_MenuMixin); var _objectAssign = __webpack_require__(229); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _util = __webpack_require__(230); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var SubPopupMenu = _react2['default'].createClass({ displayName: 'SubPopupMenu', propTypes: { onSelect: _react2['default'].PropTypes.func, onClick: _react2['default'].PropTypes.func, onDeselect: _react2['default'].PropTypes.func, onOpenChange: _react2['default'].PropTypes.func, onDestroy: _react2['default'].PropTypes.func, openTransitionName: _react2['default'].PropTypes.string, openAnimation: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.string, _react2['default'].PropTypes.object]), openKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), closeSubMenuOnMouseLeave: _react2['default'].PropTypes.bool, visible: _react2['default'].PropTypes.bool }, mixins: [_MenuMixin2['default']], onDeselect: function onDeselect(selectInfo) { this.props.onDeselect(selectInfo); }, onSelect: function onSelect(selectInfo) { this.props.onSelect(selectInfo); }, onClick: function onClick(e) { this.props.onClick(e); }, onOpenChange: function onOpenChange(e) { this.props.onOpenChange(e); }, onDestroy: function onDestroy(key) { this.props.onDestroy(key); }, onItemHover: function onItemHover(e) { this.onCommonItemHover(e); }, getOpenTransitionName: function getOpenTransitionName() { return this.props.openTransitionName; }, renderMenuItem: function renderMenuItem(c, i) { var props = this.props; var key = (0, _util.getKeyFromChildrenIndex)(c, props.eventKey, i); var extraProps = { openKeys: props.openKeys, selectedKeys: props.selectedKeys, open: props.openKeys.indexOf(key) !== -1, selected: props.selectedKeys.indexOf(key) !== -1, openSubMenuOnMouseEnter: true }; return this.renderCommonMenuItem(c, i, extraProps); }, render: function render() { var renderFirst = this.renderFirst; this.renderFirst = 1; this.haveOpened = this.haveOpened || this.props.visible; if (!this.haveOpened) { return null; } var transitionAppear = true; if (!renderFirst && this.props.visible) { transitionAppear = false; } var props = (0, _objectAssign2['default'])({}, this.props); props.className += ' ' + props.prefixCls + '-sub'; var animProps = {}; if (props.openTransitionName) { animProps.transitionName = props.openTransitionName; } else if (typeof props.openAnimation === 'object') { animProps.animation = (0, _objectAssign2['default'])({}, props.openAnimation); if (!transitionAppear) { delete animProps.animation.appear; } } return _react2['default'].createElement( _rcAnimate2['default'], _extends({}, animProps, { showProp: 'data-visible', component: '', transitionAppear: transitionAppear }), this.renderRoot(props) ); } }); exports['default'] = SubPopupMenu; module.exports = exports['default']; /***/ }, /* 233 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); exports['default'] = { componentDidMount: function componentDidMount() { this.componentDidUpdate(); }, componentDidUpdate: function componentDidUpdate() { if (this.props.mode !== 'inline') { if (this.props.open) { this.bindRootCloseHandlers(); } else { this.unbindRootCloseHandlers(); } } }, handleDocumentKeyUp: function handleDocumentKeyUp(e) { if (e.keyCode === _rcUtil.KeyCode.ESC) { this.props.onItemHover({ key: this.props.eventKey, item: this, hover: false }); } }, handleDocumentClick: function handleDocumentClick(e) { // If the click originated from within this component // don't do anything. if (_rcUtil2['default'].Dom.contains(_react2['default'].findDOMNode(this), e.target)) { return; } var props = this.props; props.onItemHover({ hover: false, item: this, key: this.props.eventKey }); this.triggerOpenChange(false); }, bindRootCloseHandlers: function bindRootCloseHandlers() { if (!this._onDocumentClickListener) { this._onDocumentClickListener = _rcUtil2['default'].Dom.addEventListener(document, 'click', this.handleDocumentClick); this._onDocumentKeyupListener = _rcUtil2['default'].Dom.addEventListener(document, 'keyup', this.handleDocumentKeyUp); } }, unbindRootCloseHandlers: function unbindRootCloseHandlers() { if (this._onDocumentClickListener) { this._onDocumentClickListener.remove(); this._onDocumentClickListener = null; } if (this._onDocumentKeyupListener) { this._onDocumentKeyupListener.remove(); this._onDocumentKeyupListener = null; } }, componentWillUnmount: function componentWillUnmount() { this.unbindRootCloseHandlers(); } }; module.exports = exports['default']; /***/ }, /* 234 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var MenuItem = (function (_React$Component) { _inherits(MenuItem, _React$Component); function MenuItem(props) { var _this = this; _classCallCheck(this, MenuItem); _get(Object.getPrototypeOf(MenuItem.prototype), 'constructor', this).call(this, props); ['onKeyDown', 'onMouseLeave', 'onMouseEnter', 'onClick'].forEach(function (m) { _this[m] = _this[m].bind(_this); }); } _createClass(MenuItem, [{ key: 'componentWillUnmount', value: function componentWillUnmount() { var props = this.props; if (props.onDestroy) { props.onDestroy(props.eventKey); } } }, { key: 'onKeyDown', value: function onKeyDown(e) { var keyCode = e.keyCode; if (keyCode === _rcUtil.KeyCode.ENTER) { this.onClick(e); return true; } } }, { key: 'onMouseLeave', value: function onMouseLeave() { var eventKey = this.props.eventKey; this.props.onItemHover({ key: eventKey, item: this, hover: false, trigger: 'mouseleave' }); } }, { key: 'onMouseEnter', value: function onMouseEnter() { var props = this.props; var eventKey = props.eventKey; props.onItemHover({ key: eventKey, item: this, hover: true, trigger: 'mouseenter' }); } }, { key: 'onClick', value: function onClick(e) { var props = this.props; var eventKey = props.eventKey; var info = { key: eventKey, keyPath: [eventKey], item: this, domEvent: e }; props.onClick(info); if (props.multiple) { if (props.selected) { props.onDeselect(info); } else { props.onSelect(info); } } else if (!props.selected) { props.onSelect(info); } } }, { key: 'getPrefixCls', value: function getPrefixCls() { return this.props.rootPrefixCls + '-item'; } }, { key: 'getActiveClassName', value: function getActiveClassName() { return this.getPrefixCls() + '-active'; } }, { key: 'getSelectedClassName', value: function getSelectedClassName() { return this.getPrefixCls() + '-selected'; } }, { key: 'getDisabledClassName', value: function getDisabledClassName() { return this.getPrefixCls() + '-disabled'; } }, { key: 'render', value: function render() { var props = this.props; var classes = {}; classes[this.getActiveClassName()] = !props.disabled && props.active; classes[this.getSelectedClassName()] = props.selected; classes[this.getDisabledClassName()] = props.disabled; classes[this.getPrefixCls()] = true; var attrs = { title: props.title, className: (0, _rcUtil.joinClasses)(props.className, (0, _rcUtil.classSet)(classes)), role: 'menuitem', 'aria-selected': props.selected, 'aria-disabled': props.disabled }; var mouseEvent = {}; if (!props.disabled) { mouseEvent = { onClick: this.onClick, onMouseLeave: this.onMouseLeave, onMouseEnter: this.onMouseEnter }; } var style = {}; if (props.mode === 'inline') { style.paddingLeft = props.inlineIndent * props.level; } return _react2['default'].createElement( 'li', _extends({ style: style }, attrs, mouseEvent), props.children ); } }]); return MenuItem; })(_react2['default'].Component); MenuItem.propTypes = { rootPrefixCls: _react2['default'].PropTypes.string, eventKey: _react2['default'].PropTypes.string, active: _react2['default'].PropTypes.bool, selected: _react2['default'].PropTypes.bool, disabled: _react2['default'].PropTypes.bool, title: _react2['default'].PropTypes.string, onSelect: _react2['default'].PropTypes.func, onClick: _react2['default'].PropTypes.func, onDeselect: _react2['default'].PropTypes.func, onItemHover: _react2['default'].PropTypes.func, onDestroy: _react2['default'].PropTypes.func }; MenuItem.defaultProps = { onSelect: function onSelect() {}, onMouseEnter: function onMouseEnter() {} }; exports['default'] = MenuItem; module.exports = exports['default']; /***/ }, /* 235 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var MenuItemGroup = (function (_React$Component) { _inherits(MenuItemGroup, _React$Component); function MenuItemGroup() { _classCallCheck(this, MenuItemGroup); _get(Object.getPrototypeOf(MenuItemGroup.prototype), 'constructor', this).apply(this, arguments); } _createClass(MenuItemGroup, [{ key: 'render', value: function render() { var props = this.props; var className = props.className || ''; var rootPrefixCls = props.rootPrefixCls; className += ' ' + rootPrefixCls + '-item-group'; var titleClassName = rootPrefixCls + '-item-group-title'; var listClassName = rootPrefixCls + '-item-group-list'; return _react2['default'].createElement( 'li', { className: className }, _react2['default'].createElement( 'div', { className: titleClassName }, props.title ), _react2['default'].createElement( 'ul', { className: listClassName }, _react2['default'].Children.map(props.children, props.renderMenuItem) ) ); } }]); return MenuItemGroup; })(_react2['default'].Component); MenuItemGroup.defaultProps = { // skip key down loop disabled: true }; exports['default'] = MenuItemGroup; module.exports = exports['default']; /***/ }, /* 236 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var Divider = (function (_React$Component) { _inherits(Divider, _React$Component); function Divider() { _classCallCheck(this, Divider); _get(Object.getPrototypeOf(Divider.prototype), 'constructor', this).apply(this, arguments); } _createClass(Divider, [{ key: 'render', value: function render() { var props = this.props; var className = props.className || ''; var rootPrefixCls = props.rootPrefixCls; className += ' ' + (rootPrefixCls + '-item-divider'); return _react2['default'].createElement('li', _extends({}, props, { className: className })); } }]); return Divider; })(_react2['default'].Component); Divider.defaultProps = { disabled: true }; exports['default'] = Divider; module.exports = exports['default']; /***/ }, /* 237 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _util = __webpack_require__(222); var _rcMenu = __webpack_require__(223); var _rcMenu2 = _interopRequireDefault(_rcMenu); var Panel = _react2['default'].createClass({ displayName: 'Panel', propTypes: { prefixCls: _react2['default'].PropTypes.string, menuItems: _react2['default'].PropTypes.any, search: _react2['default'].PropTypes.any }, shouldComponentUpdate: function shouldComponentUpdate(nextProps) { return nextProps.visible; }, getDropdownPrefixCls: function getDropdownPrefixCls() { return this.props.prefixCls + '-dropdown'; }, renderMenu: function renderMenu() { var props = this.props; var menuItems = props.menuItems; if (menuItems && menuItems.length) { var menuProps = {}; if (props.isMultipleOrTags) { menuProps.onDeselect = props.onMenuDeselect; menuProps.onSelect = props.onMenuSelect; } else { menuProps.onClick = props.onMenuSelect; } var value = props.value; var selectedKeys = (0, _util.getSelectKeys)(menuItems, value); var activeKey = undefined; if (!props.isMultipleOrTags) { if (!activeKey && selectedKeys.length === 1) { activeKey = selectedKeys[0]; } } return _react2['default'].createElement( _rcMenu2['default'], _extends({ ref: 'menu', style: props.dropdownMenuStyle, defaultActiveFirst: true, activeKey: activeKey, multiple: props.isMultipleOrTags, focusable: false }, menuProps, { selectedKeys: selectedKeys, prefixCls: this.getDropdownPrefixCls() + '-menu' }), menuItems ); } return null; }, render: function render() { return _react2['default'].createElement( 'div', null, this.props.search, this.renderMenu() ); } }); exports['default'] = Panel; module.exports = exports['default']; /***/ }, /* 238 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // export this package's api Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Align = __webpack_require__(239); var _Align2 = _interopRequireDefault(_Align); exports['default'] = _Align2['default']; module.exports = exports['default']; /***/ }, /* 239 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _domAlign = __webpack_require__(240); var _domAlign2 = _interopRequireDefault(_domAlign); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); function isWindow(obj) { /*eslint-disable eqeqeq */ return obj != null && obj == obj.window; /*eslint-enable eqeqeq */ } function buffer(fn, ms) { var timer; return function () { if (timer) { clearTimeout(timer); } timer = setTimeout(fn, ms); }; } var Align = (function (_React$Component) { _inherits(Align, _React$Component); function Align(props) { _classCallCheck(this, Align); _get(Object.getPrototypeOf(Align.prototype), 'constructor', this).apply(this, arguments); this.handleWindowResize = this.handleWindowResize.bind(this); } _createClass(Align, [{ key: 'componentDidMount', value: function componentDidMount() { var props = this.props; // if parent ref not attached .... use document.getElementById if (!props.disabled) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); if (props.monitorWindowResize) { this.startMonitorWindowResize(); } } } }, { key: 'startMonitorWindowResize', value: function startMonitorWindowResize() { if (!this.resizeHandler) { this.resizeHandler = _rcUtil2['default'].Dom.addEventListener(window, 'resize', buffer(this.handleWindowResize, this.props.monitorBufferTime)); } } }, { key: 'stopMonitorWindowResize', value: function stopMonitorWindowResize() { if (this.resizeHandler) { this.resizeHandler.remove(); this.resizeHandler = null; } } }, { key: 'handleWindowResize', value: function handleWindowResize() { var props = this.props; if (!props.disabled) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.stopMonitorWindowResize(); } }, { key: 'componentDidUpdate', value: function componentDidUpdate(prevProps) { var reAlign = false; var props = this.props; var currentTarget; if (!props.disabled) { if (prevProps.disabled || prevProps.align !== props.align) { reAlign = true; currentTarget = props.target(); } else { var lastTarget = prevProps.target(); currentTarget = props.target(); if (isWindow(lastTarget) && isWindow(currentTarget)) { reAlign = false; } else if (lastTarget !== currentTarget) { reAlign = true; } } } if (reAlign) { var source = _react2['default'].findDOMNode(this); props.onAlign(source, (0, _domAlign2['default'])(source, currentTarget, props.align)); } if (props.monitorWindowResize && !props.disabled) { this.startMonitorWindowResize(); } else { this.stopMonitorWindowResize(); } } }, { key: 'render', value: function render() { return _react2['default'].Children.only(this.props.children); } }]); return Align; })(_react2['default'].Component); Align.defaultProps = { target: function target() { return window; }, onAlign: function onAlign() {}, monitorBufferTime: 50, monitorWindowResize: false, disabled: false }; Align.PropTypes = { align: _react2['default'].PropTypes.object.isRequired, target: _react2['default'].PropTypes.func, onAlign: _react2['default'].PropTypes.func, monitorBufferTime: _react2['default'].PropTypes.number, monitorWindowResize: _react2['default'].PropTypes.bool, disabled: _react2['default'].PropTypes.bool }; exports['default'] = Align; module.exports = exports['default']; /***/ }, /* 240 */ /***/ function(module, exports, __webpack_require__) { /** * align dom node flexibly * @author yiminghe@gmail.com */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(241); var _utils2 = _interopRequireDefault(_utils); var _getOffsetParent = __webpack_require__(242); var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); var _getVisibleRectForElement = __webpack_require__(243); var _getVisibleRectForElement2 = _interopRequireDefault(_getVisibleRectForElement); var _adjustForViewport = __webpack_require__(244); var _adjustForViewport2 = _interopRequireDefault(_adjustForViewport); var _getRegion = __webpack_require__(245); var _getRegion2 = _interopRequireDefault(_getRegion); var _getElFuturePos = __webpack_require__(246); var _getElFuturePos2 = _interopRequireDefault(_getElFuturePos); // http://yiminghe.iteye.com/blog/1124720 function isFailX(elFuturePos, elRegion, visibleRect) { return elFuturePos.left < visibleRect.left || elFuturePos.left + elRegion.width > visibleRect.right; } function isFailY(elFuturePos, elRegion, visibleRect) { return elFuturePos.top < visibleRect.top || elFuturePos.top + elRegion.height > visibleRect.bottom; } function flip(points, reg, map) { var ret = []; _utils2['default'].each(points, function (p) { ret.push(p.replace(reg, function (m) { return map[m]; })); }); return ret; } function flipOffset(offset, index) { offset[index] = -offset[index]; return offset; } function convertOffset(str, offsetLen) { var n = undefined; if (/%$/.test(str)) { n = parseInt(str.substring(0, str.length - 1), 10) / 100 * offsetLen; } else { n = parseInt(str, 10); } return n || 0; } function normalizeOffset(offset, el) { offset[0] = convertOffset(offset[0], el.width); offset[1] = convertOffset(offset[1], el.height); } /* * align node * @param {Element} node current dom node * @param {Object} align align config * * @example * { * node: null, // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素 * points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tr 与参考节点的 tl 对齐 * offset: [0, 0] // 有效值为 [n, m] * } */ function domAlign(el, refNode, align) { var points = align.points; var offset = align.offset || [0, 0]; var targetOffset = align.targetOffset || [0, 0]; var overflow = align.overflow; offset = [].concat(offset); targetOffset = [].concat(targetOffset); overflow = overflow || {}; var newOverflowCfg = {}; var fail = 0; // 当前节点可以被放置的显示区域 var visibleRect = (0, _getVisibleRectForElement2['default'])(el); // 当前节点所占的区域, left/top/width/height var elRegion = (0, _getRegion2['default'])(el); // 参照节点所占的区域, left/top/width/height var refNodeRegion = (0, _getRegion2['default'])(refNode); // 将 offset 转换成数值,支持百分比 normalizeOffset(offset, elRegion); normalizeOffset(targetOffset, refNodeRegion); // 当前节点将要被放置的位置 var elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); // 当前节点将要所处的区域 var newElRegion = _utils2['default'].merge(elRegion, elFuturePos); // 如果可视区域不能完全放置当前节点时允许调整 if (visibleRect && (overflow.adjustX || overflow.adjustY)) { if (overflow.adjustX) { // 如果横向不能放下 if (isFailX(elFuturePos, elRegion, visibleRect)) { fail = 1; // 对齐位置反下 points = flip(points, /[lr]/ig, { l: 'r', r: 'l' }); // 偏移量也反下 offset = flipOffset(offset, 0); targetOffset = flipOffset(targetOffset, 0); } } if (overflow.adjustY) { // 如果纵向不能放下 if (isFailY(elFuturePos, elRegion, visibleRect)) { fail = 1; // 对齐位置反下 points = flip(points, /[tb]/ig, { t: 'b', b: 't' }); // 偏移量也反下 offset = flipOffset(offset, 1); targetOffset = flipOffset(targetOffset, 1); } } // 如果失败,重新计算当前节点将要被放置的位置 if (fail) { elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); _utils2['default'].mix(newElRegion, elFuturePos); } // 检查反下后的位置是否可以放下了 // 如果仍然放不下只有指定了可以调整当前方向才调整 newOverflowCfg.adjustX = overflow.adjustX && isFailX(elFuturePos, elRegion, visibleRect); newOverflowCfg.adjustY = overflow.adjustY && isFailY(elFuturePos, elRegion, visibleRect); // 确实要调整,甚至可能会调整高度宽度 if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) { newElRegion = (0, _adjustForViewport2['default'])(elFuturePos, elRegion, visibleRect, newOverflowCfg); } } // https://github.com/kissyteam/kissy/issues/190 // http://localhost:8888/kissy/src/overlay/demo/other/relative_align/align.html // 相对于屏幕位置没变,而 left/top 变了 // 例如 <div 'relative'><el absolute></div> _utils2['default'].offset(el, { left: newElRegion.left, top: newElRegion.top }); // need judge to in case set fixed with in css on height auto element if (newElRegion.width !== elRegion.width) { _utils2['default'].css(el, 'width', el.width() + newElRegion.width - elRegion.width); } if (newElRegion.height !== elRegion.height) { _utils2['default'].css(el, 'height', el.height() + newElRegion.height - elRegion.height); } return { points: points, offset: offset, targetOffset: targetOffset, overflow: newOverflowCfg }; } domAlign.__getOffsetParent = _getOffsetParent2['default']; domAlign.__getVisibleRectForElement = _getVisibleRectForElement2['default']; exports['default'] = domAlign; /** * 2012-04-26 yiminghe@gmail.com * - 优化智能对齐算法 * - 慎用 resizeXX * * 2011-07-13 yiminghe@gmail.com note: * - 增加智能对齐,以及大小调整选项 **/ module.exports = exports['default']; /***/ }, /* 241 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; var getComputedStyleX = undefined; function css(el, name, v) { var value = v; if (typeof name === 'object') { for (var i in name) { if (name.hasOwnProperty(i)) { css(el, i, name[i]); } } return undefined; } if (typeof value !== 'undefined') { if (typeof value === 'number') { value = value + 'px'; } el.style[name] = value; return undefined; } return getComputedStyleX(el, name); } function getClientPosition(elem) { var box = undefined; var x = undefined; var y = undefined; var doc = elem.ownerDocument; var body = doc.body; var docElem = doc && doc.documentElement; // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 box = elem.getBoundingClientRect(); // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin x = box.left; y = box.top; // In IE, most of the time, 2 extra pixels are added to the top and left // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and // IE6 standards mode, this border can be overridden by setting the // document element's border to zero -- thus, we cannot rely on the // offset always being 2 pixels. // In quirks mode, the offset can be determined by querying the body's // clientLeft/clientTop, but in standards mode, it is found by querying // the document element's clientLeft/clientTop. Since we already called // getClientBoundingRect we have already forced a reflow, so it is not // too expensive just to query them all. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 // 窗口边框标准是设 documentElement ,quirks 时设置 body // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 // 标准 ie 下 docElem.clientTop 就是 border-top // ie7 html 即窗口边框改变不了。永远为 2 // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 x -= docElem.clientLeft || body.clientLeft || 0; y -= docElem.clientTop || body.clientTop || 0; return { left: x, top: y }; } function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; // ie6,7,8 standard mode ret = d.documentElement[method]; if (typeof ret !== 'number') { // quirks mode ret = d.body[method]; } } return ret; } function getScrollLeft(w) { return getScroll(w); } function getScrollTop(w) { return getScroll(w, true); } function getOffset(el) { var pos = getClientPosition(el); var doc = el.ownerDocument; var w = doc.defaultView || doc.parentWindow; pos.left += getScrollLeft(w); pos.top += getScrollTop(w); return pos; } function _getComputedStyle(elem, name, cs) { var computedStyle = cs; var val = ''; var d = elem.ownerDocument; // https://github.com/kissyteam/kissy/issues/61 if (computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null)) { val = computedStyle.getPropertyValue(name) || computedStyle[name]; } return val; } var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); var RE_POS = /^(top|right|bottom|left)$/; var CURRENT_STYLE = 'currentStyle'; var RUNTIME_STYLE = 'runtimeStyle'; var LEFT = 'left'; var PX = 'px'; function _getComputedStyleIE(elem, name) { // currentStyle maybe null // http://msdn.microsoft.com/en-us/library/ms535231.aspx var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 // 在 ie 下不对,需要直接用 offset 方式 // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // If we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels // exclude left right for relativity if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { // Remember the original values var style = elem.style; var left = style[LEFT]; var rsLeft = elem[RUNTIME_STYLE][LEFT]; // prevent flashing of content elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; // Put in the new values to get a computed value out style[LEFT] = name === 'fontSize' ? '1em' : ret || 0; ret = style.pixelLeft + PX; // Revert the changed values style[LEFT] = left; elem[RUNTIME_STYLE][LEFT] = rsLeft; } return ret === '' ? 'auto' : ret; } if (typeof window !== 'undefined') { getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; } // 设置 elem 相对 elem.ownerDocument 的坐标 function setOffset(elem, offset) { // set position first, in-case top/left are set even on static elem if (css(elem, 'position') === 'static') { elem.style.position = 'relative'; } var preset = -9999; if ('left' in offset) { elem.style.left = preset + 'px'; } if ('top' in offset) { elem.style.top = preset + 'px'; } var old = getOffset(elem); var ret = {}; var key = undefined; for (key in offset) { if (offset.hasOwnProperty(key)) { ret[key] = preset + offset[key] - old[key]; } } css(elem, ret); } function each(arr, fn) { for (var i = 0; i < arr.length; i++) { fn(arr[i]); } } function isBorderBoxFn(elem) { return getComputedStyleX(elem, 'boxSizing') === 'border-box'; } var BOX_MODELS = ['margin', 'border', 'padding']; var CONTENT_INDEX = -1; var PADDING_INDEX = 2; var BORDER_INDEX = 1; var MARGIN_INDEX = 0; function swap(elem, options, callback) { var old = {}; var style = elem.style; var name = undefined; // Remember the old values, and insert the new ones for (name in options) { if (options.hasOwnProperty(name)) { old[name] = style[name]; style[name] = options[name]; } } callback.call(elem); // Revert the old values for (name in options) { if (options.hasOwnProperty(name)) { style[name] = old[name]; } } } function getPBMWidth(elem, props, which) { var value = 0; var prop = undefined; var j = undefined; var i = undefined; for (j = 0; j < props.length; j++) { prop = props[j]; if (prop) { for (i = 0; i < which.length; i++) { var cssProp = undefined; if (prop === 'border') { cssProp = prop + which[i] + 'Width'; } else { cssProp = prop + which[i]; } value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; } } } return value; } /** * A crude way of determining if an object is a window * @member util */ function isWindow(obj) { // must use == for ie8 /* eslint eqeqeq:0 */ return obj !== null && obj !== undefined && obj == obj.window; } var domUtils = {}; each(['Width', 'Height'], function (name) { domUtils['doc' + name] = function (refWin) { var d = refWin.document; return Math.max( // firefox chrome documentElement.scrollHeight< body.scrollHeight // ie standard mode : documentElement.scrollHeight> body.scrollHeight d.documentElement['scroll' + name], // quirks : documentElement.scrollHeight 最大等于可视窗口多一点? d.body['scroll' + name], domUtils['viewport' + name](d)); }; domUtils['viewport' + name] = function (win) { // pc browser includes scrollbar in window.innerWidth var prop = 'client' + name; var doc = win.document; var body = doc.body; var documentElement = doc.documentElement; var documentElementProp = documentElement[prop]; // 标准模式取 documentElement // backcompat 取 body return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp; }; }); /* 得到元素的大小信息 @param elem @param name @param {String} [extra] 'padding' : (css width) + padding 'border' : (css width) + padding + border 'margin' : (css width) + padding + border + margin */ function getWH(elem, name, ex) { var extra = ex; if (isWindow(elem)) { return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); } else if (elem.nodeType === 9) { return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); } var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem, computedStyle); var cssBoxValue = 0; if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) { borderBoxValue = undefined; // Fall back to computed then un computed css if necessary cssBoxValue = getComputedStyleX(elem, name); if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) { cssBoxValue = elem.style[name] || 0; } // Normalize '', auto, and prepare for extra cssBoxValue = parseFloat(cssBoxValue) || 0; } if (extra === undefined) { extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; } var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; var val = borderBoxValue || cssBoxValue; if (extra === CONTENT_INDEX) { if (borderBoxValueOrIsBorderBox) { return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle); } return cssBoxValue; } else if (borderBoxValueOrIsBorderBox) { if (extra === BORDER_INDEX) { return val; } return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle)); } return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle); } var cssShow = { position: 'absolute', visibility: 'hidden', display: 'block' }; // fix #119 : https://github.com/kissyteam/kissy/issues/119 function getWHIgnoreDisplay() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var val = undefined; var elem = args[0]; // in case elem is window // elem.offsetWidth === undefined if (elem.offsetWidth !== 0) { val = getWH.apply(undefined, args); } else { swap(elem, cssShow, function () { val = getWH.apply(undefined, args); }); } return val; } each(['width', 'height'], function (name) { var first = name.charAt(0).toUpperCase() + name.slice(1); domUtils['outer' + first] = function (el, includeMargin) { return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); }; var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; domUtils[name] = function (elem, v) { var val = v; if (val !== undefined) { if (elem) { var computedStyle = getComputedStyleX(elem); var isBorderBox = isBorderBoxFn(elem); if (isBorderBox) { val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); } return css(elem, name, val); } return undefined; } return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); }; }); function mix(to, from) { for (var i in from) { if (from.hasOwnProperty(i)) { to[i] = from[i]; } } return to; } var utils = { getWindow: function getWindow(node) { if (node && node.document && node.setTimeout) { return node; } var doc = node.ownerDocument || node; return doc.defaultView || doc.parentWindow; }, offset: function offset(el, value) { if (typeof value !== 'undefined') { setOffset(el, value); } else { return getOffset(el); } }, isWindow: isWindow, each: each, css: css, clone: function clone(obj) { var i = undefined; var ret = {}; for (i in obj) { if (obj.hasOwnProperty(i)) { ret[i] = obj[i]; } } var overflow = obj.overflow; if (overflow) { for (i in obj) { if (obj.hasOwnProperty(i)) { ret.overflow[i] = obj.overflow[i]; } } } return ret; }, mix: mix, getWindowScrollLeft: function getWindowScrollLeft(w) { return getScrollLeft(w); }, getWindowScrollTop: function getWindowScrollTop(w) { return getScrollTop(w); }, merge: function merge() { var ret = {}; for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } for (var i = 0; i < args.length; i++) { utils.mix(ret, args[i]); } return ret; }, viewportWidth: 0, viewportHeight: 0 }; mix(utils, domUtils); exports['default'] = utils; module.exports = exports['default']; /***/ }, /* 242 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(241); var _utils2 = _interopRequireDefault(_utils); /** * 得到会导致元素显示不全的祖先元素 */ function getOffsetParent(element) { // ie 这个也不是完全可行 /* <div style="width: 50px;height: 100px;overflow: hidden"> <div style="width: 50px;height: 100px;position: relative;" id="d6"> 元素 6 高 100px 宽 50px<br/> </div> </div> */ // element.offsetParent does the right thing in ie7 and below. Return parent with layout! // In other browsers it only includes elements with position absolute, relative or // fixed, not elements with overflow set to auto or scroll. // if (UA.ie && ieMode < 8) { // return element.offsetParent; // } // 统一的 offsetParent 方法 var doc = element.ownerDocument; var body = doc.body; var parent = undefined; var positionStyle = _utils2['default'].css(element, 'position'); var skipStatic = positionStyle === 'fixed' || positionStyle === 'absolute'; if (!skipStatic) { return element.nodeName.toLowerCase() === 'html' ? null : element.parentNode; } for (parent = element.parentNode; parent && parent !== body; parent = parent.parentNode) { positionStyle = _utils2['default'].css(parent, 'position'); if (positionStyle !== 'static') { return parent; } } return null; } exports['default'] = getOffsetParent; module.exports = exports['default']; /***/ }, /* 243 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(241); var _utils2 = _interopRequireDefault(_utils); var _getOffsetParent = __webpack_require__(242); var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); /** * 获得元素的显示部分的区域 */ function getVisibleRectForElement(element) { var visibleRect = { left: 0, right: Infinity, top: 0, bottom: Infinity }; var el = (0, _getOffsetParent2['default'])(element); var scrollX = undefined; var scrollY = undefined; var winSize = undefined; var doc = element.ownerDocument; var win = doc.defaultView || doc.parentWindow; var body = doc.body; var documentElement = doc.documentElement; // Determine the size of the visible rect by climbing the dom accounting for // all scrollable containers. while (el) { // clientWidth is zero for inline block elements in ie. if ((navigator.userAgent.indexOf('MSIE') === -1 || el.clientWidth !== 0) && ( // body may have overflow set on it, yet we still get the entire // viewport. In some browsers, el.offsetParent may be // document.documentElement, so check for that too. el !== body && el !== documentElement && _utils2['default'].css(el, 'overflow') !== 'visible')) { var pos = _utils2['default'].offset(el); // add border pos.left += el.clientLeft; pos.top += el.clientTop; visibleRect.top = Math.max(visibleRect.top, pos.top); visibleRect.right = Math.min(visibleRect.right, // consider area without scrollBar pos.left + el.clientWidth); visibleRect.bottom = Math.min(visibleRect.bottom, pos.top + el.clientHeight); visibleRect.left = Math.max(visibleRect.left, pos.left); } else if (el === body || el === documentElement) { break; } el = (0, _getOffsetParent2['default'])(el); } // Clip by window's viewport. scrollX = _utils2['default'].getWindowScrollLeft(win); scrollY = _utils2['default'].getWindowScrollTop(win); visibleRect.left = Math.max(visibleRect.left, scrollX); visibleRect.top = Math.max(visibleRect.top, scrollY); winSize = { width: _utils2['default'].viewportWidth(win), height: _utils2['default'].viewportHeight(win) }; visibleRect.right = Math.min(visibleRect.right, scrollX + winSize.width); visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + winSize.height); return visibleRect.top >= 0 && visibleRect.left >= 0 && visibleRect.bottom > visibleRect.top && visibleRect.right > visibleRect.left ? visibleRect : null; } exports['default'] = getVisibleRectForElement; module.exports = exports['default']; /***/ }, /* 244 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(241); var _utils2 = _interopRequireDefault(_utils); function adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) { var pos = _utils2['default'].clone(elFuturePos); var size = { width: elRegion.width, height: elRegion.height }; if (overflow.adjustX && pos.left < visibleRect.left) { pos.left = visibleRect.left; } // Left edge inside and right edge outside viewport, try to resize it. if (overflow.resizeWidth && pos.left >= visibleRect.left && pos.left + size.width > visibleRect.right) { size.width -= pos.left + size.width - visibleRect.right; } // Right edge outside viewport, try to move it. if (overflow.adjustX && pos.left + size.width > visibleRect.right) { // 保证左边界和可视区域左边界对齐 pos.left = Math.max(visibleRect.right - size.width, visibleRect.left); } // Top edge outside viewport, try to move it. if (overflow.adjustY && pos.top < visibleRect.top) { pos.top = visibleRect.top; } // Top edge inside and bottom edge outside viewport, try to resize it. if (overflow.resizeHeight && pos.top >= visibleRect.top && pos.top + size.height > visibleRect.bottom) { size.height -= pos.top + size.height - visibleRect.bottom; } // Bottom edge outside viewport, try to move it. if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) { // 保证上边界和可视区域上边界对齐 pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top); } return _utils2['default'].mix(pos, size); } exports['default'] = adjustForViewport; module.exports = exports['default']; /***/ }, /* 245 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _utils = __webpack_require__(241); var _utils2 = _interopRequireDefault(_utils); function getRegion(node) { var offset = undefined; var w = undefined; var h = undefined; if (!_utils2['default'].isWindow(node) && node.nodeType !== 9) { offset = _utils2['default'].offset(node); w = _utils2['default'].outerWidth(node); h = _utils2['default'].outerHeight(node); } else { var win = _utils2['default'].getWindow(node); offset = { left: _utils2['default'].getWindowScrollLeft(win), top: _utils2['default'].getWindowScrollTop(win) }; w = _utils2['default'].viewportWidth(win); h = _utils2['default'].viewportHeight(win); } offset.width = w; offset.height = h; return offset; } exports['default'] = getRegion; module.exports = exports['default']; /***/ }, /* 246 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _getAlignOffset = __webpack_require__(247); var _getAlignOffset2 = _interopRequireDefault(_getAlignOffset); function getElFuturePos(elRegion, refNodeRegion, points, offset, targetOffset) { var xy = undefined; var diff = undefined; var p1 = undefined; var p2 = undefined; xy = { left: elRegion.left, top: elRegion.top }; p1 = (0, _getAlignOffset2['default'])(refNodeRegion, points[1]); p2 = (0, _getAlignOffset2['default'])(elRegion, points[0]); diff = [p2.left - p1.left, p2.top - p1.top]; return { left: xy.left - diff[0] + offset[0] - targetOffset[0], top: xy.top - diff[1] + offset[1] - targetOffset[1] }; } exports['default'] = getElFuturePos; module.exports = exports['default']; /***/ }, /* 247 */ /***/ function(module, exports) { /** * 获取 node 上的 align 对齐点 相对于页面的坐标 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function getAlignOffset(region, align) { var V = align.charAt(0); var H = align.charAt(1); var w = region.width; var h = region.height; var x = undefined; var y = undefined; x = region.left; y = region.top; if (V === 'c') { y += h / 2; } else if (V === 'b') { y += h; } if (H === 'c') { x += w / 2; } else if (H === 'r') { x += w; } return { left: x, top: y }; } exports['default'] = getAlignOffset; module.exports = exports['default']; /***/ }, /* 248 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var Option = (function (_React$Component) { _inherits(Option, _React$Component); function Option() { _classCallCheck(this, Option); _get(Object.getPrototypeOf(Option.prototype), 'constructor', this).apply(this, arguments); } return Option; })(_react2['default'].Component); exports['default'] = Option; module.exports = exports['default']; /***/ }, /* 249 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var prefixCls = 'ant-breadcrumb'; var BreadcrumbItem = _react2['default'].createClass({ displayName: 'BreadcrumbItem', propTypes: { href: _react2['default'].PropTypes.string }, render: function render() { var link = _react2['default'].createElement( 'a', _extends({ className: prefixCls + '-link' }, this.props), this.props.children ); var slash = _react2['default'].createElement( 'span', { className: prefixCls + '-slash' }, '/' ); if (typeof this.props.href === 'undefined') { link = _react2['default'].createElement( 'span', _extends({ className: prefixCls + '-link' }, this.props), this.props.children ); } return _react2['default'].createElement( 'span', null, link, slash ); } }); var Breadcrumb = _react2['default'].createClass({ displayName: 'Breadcrumb', propTypes: { router: _react2['default'].PropTypes.object, routes: _react2['default'].PropTypes.array, params: _react2['default'].PropTypes.object }, render: function render() { var crumbs = undefined; var ReactRouter = this.props.router; var routes = this.props.routes; var params = this.props.params; if (routes && routes.length > 0 && ReactRouter) { (function () { var Link = ReactRouter.Link; crumbs = routes.map(function (route, i) { var name = route.breadcrumbName.replace(/\:(.*)/g, function (replacement, key) { return params[key] || replacement; }); var link = undefined; var path = route.path.indexOf('/') === 0 ? route.path : '/' + route.path; if (i === routes.length - 1) { link = _react2['default'].createElement( 'span', null, name ); } else { link = _react2['default'].createElement( Link, { to: path, params: params }, name ); } return _react2['default'].createElement( BreadcrumbItem, { key: name }, link ); }); })(); } else { crumbs = this.props.children; } return _react2['default'].createElement( 'div', { className: prefixCls }, crumbs ); } }); Breadcrumb.Item = BreadcrumbItem; exports['default'] = Breadcrumb; module.exports = exports['default']; /***/ }, /* 250 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcTooltip = __webpack_require__(137); var _rcTooltip2 = _interopRequireDefault(_rcTooltip); var prefixCls = 'ant-popover'; exports['default'] = _react2['default'].createClass({ displayName: 'index', getInitialState: function getInitialState() { return { visible: false }; }, getDefaultProps: function getDefaultProps() { return { transitionName: '', placement: 'top', trigger: 'click', overlayStyle: {}, onConfirm: function onConfirm() {}, onCancel: function onCancel() {} }; }, confirm: function confirm() { this.props.onConfirm.call(this); this.setState({ visible: false }); }, cancel: function cancel() { this.props.onCancel.call(this); this.setState({ visible: false }); }, onVisibleChange: function onVisibleChange(v) { this.setState({ visible: v }); }, render: function render() { var overlay = _react2['default'].createElement( 'div', null, _react2['default'].createElement( 'div', { className: prefixCls + '-content' }, _react2['default'].createElement( 'p', { className: prefixCls + '-message' }, _react2['default'].createElement('i', { className: 'anticon anticon-exclamation-circle' }), this.props.title ), _react2['default'].createElement( 'div', { className: prefixCls + '-buttons' }, _react2['default'].createElement( 'button', { onClick: this.cancel, className: 'ant-btn ant-btn-sm' }, '取 消' ), _react2['default'].createElement( 'button', { onClick: this.confirm, className: 'ant-btn ant-btn-primary ant-btn-sm' }, '确 定' ) ) ) ); var transitionName = ({ top: 'zoom-down', bottom: 'zoom-up', left: 'zoom-right', right: 'zoom-left' })[this.props.placement]; return _react2['default'].createElement( _rcTooltip2['default'], { placement: this.props.placement, overlayStyle: this.props.overlayStyle, prefixCls: prefixCls, onVisibleChange: this.onVisibleChange, transitionName: transitionName, visible: this.state.visible, trigger: this.props.trigger, overlay: overlay }, this.props.children ); } }); module.exports = exports['default']; /***/ }, /* 251 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcPagination = __webpack_require__(252); var _rcPagination2 = _interopRequireDefault(_rcPagination); var _rcSelect = __webpack_require__(218); var _rcSelect2 = _interopRequireDefault(_rcSelect); var prefixCls = 'ant-pagination'; var AntPagination = (function (_React$Component) { _inherits(AntPagination, _React$Component); function AntPagination() { _classCallCheck(this, AntPagination); _get(Object.getPrototypeOf(AntPagination.prototype), 'constructor', this).apply(this, arguments); } _createClass(AntPagination, [{ key: 'render', value: function render() { return _react2['default'].createElement(_rcPagination2['default'], _extends({ selectComponentClass: _rcSelect2['default'], selectPrefixCls: 'ant-select', prefixCls: prefixCls }, this.props)); } }]); return AntPagination; })(_react2['default'].Component); exports['default'] = AntPagination; module.exports = exports['default']; /***/ }, /* 252 */ /***/ function(module, exports, __webpack_require__) { // export this package's api 'use strict'; module.exports = __webpack_require__(253); /***/ }, /* 253 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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) subClass.__proto__ = superClass; } var React = __webpack_require__(76); var Pager = __webpack_require__(254); var Options = __webpack_require__(255); var KEYCODE = __webpack_require__(256); function noop() {} var Pagination = (function (_React$Component) { _inherits(Pagination, _React$Component); function Pagination(props) { var _this = this; _classCallCheck(this, Pagination); _get(Object.getPrototypeOf(Pagination.prototype), 'constructor', this).call(this, props); this.state = { current: props.current, _current: props.current, pageSize: props.pageSize }; ['render', '_handleChange', '_handleKeyUp', '_handleKeyDown', '_changePageSize', '_isValid', '_prev', '_next', '_hasPrev', '_hasNext', '_jumpPrev', '_jumpNext'].forEach(function (method) { return _this[method] = _this[method].bind(_this); }); } _createClass(Pagination, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { if ('current' in nextProps) { this.setState({ current: nextProps.current }); } if ('pageSize' in nextProps) { this.setState({ pageSize: nextProps.pageSize }); } } }, { key: 'render', value: function render() { var props = this.props; var prefixCls = props.prefixCls; var allPages = this._calcPage(); var pagerList = []; var jumpPrev = null; var jumpNext = null; var firstPager = null; var lastPager = null; if (props.simple) { return React.createElement( 'ul', { className: prefixCls + ' ' + prefixCls + '-simple ' + props.className }, React.createElement( 'li', { title: 'Previous Page', onClick: this._prev, className: (this._hasPrev() ? '' : prefixCls + '-disabled ') + (prefixCls + '-prev') }, React.createElement('a', null) ), React.createElement( 'div', { title: 'Page ' + this.state.current + ' of ' + allPages, className: prefixCls + '-simple-pager' }, React.createElement('input', { type: 'text', value: this.state._current, onKeyDown: this._handleKeyDown, onKeyUp: this._handleKeyUp, onChange: this._handleKeyUp }), React.createElement( 'span', { className: prefixCls + '-slash' }, '/' ), allPages ), React.createElement( 'li', { title: 'Next Page', onClick: this._next, className: (this._hasNext() ? '' : prefixCls + '-disabled ') + (prefixCls + '-next') }, React.createElement('a', null) ) ); } if (allPages <= 9) { for (var i = 1; i <= allPages; i++) { var active = this.state.current === i; pagerList.push(React.createElement(Pager, { rootPrefixCls: prefixCls, onClick: this._handleChange.bind(this, i), key: i, page: i, active: active })); } } else { jumpPrev = React.createElement( 'li', { title: 'Previous 5 Page', key: 'prev', onClick: this._jumpPrev, className: prefixCls + '-jump-prev' }, React.createElement('a', null) ); jumpNext = React.createElement( 'li', { title: 'Next 5 Page', key: 'next', onClick: this._jumpNext, className: prefixCls + '-jump-next' }, React.createElement('a', null) ); lastPager = React.createElement(Pager, { last: true, rootPrefixCls: prefixCls, onClick: this._handleChange.bind(this, allPages), key: allPages, page: allPages, active: false }); firstPager = React.createElement(Pager, { rootPrefixCls: prefixCls, onClick: this._handleChange.bind(this, 1), key: 1, page: 1, active: false }); var current = this.state.current; var left = Math.max(1, current - 2), right = Math.min(current + 2, allPages); if (current - 1 <= 2) { right = 1 + 4; } if (allPages - current <= 2) { left = allPages - 4; } for (var i = left; i <= right; i++) { var active = current === i; pagerList.push(React.createElement(Pager, { rootPrefixCls: prefixCls, onClick: this._handleChange.bind(this, i), key: i, page: i, active: active })); } if (current - 1 >= 4) { pagerList.unshift(jumpPrev); } if (allPages - current >= 4) { pagerList.push(jumpNext); } if (left !== 1) { pagerList.unshift(firstPager); } if (right !== allPages) { pagerList.push(lastPager); } } return React.createElement( 'ul', { className: prefixCls + ' ' + props.className, unselectable: 'unselectable' }, React.createElement( 'li', { title: 'Previous Page', onClick: this._prev, className: (this._hasPrev() ? '' : prefixCls + '-disabled ') + (prefixCls + '-prev') }, React.createElement('a', null) ), pagerList, React.createElement( 'li', { title: 'Next Page', onClick: this._next, className: (this._hasNext() ? '' : prefixCls + '-disabled ') + (prefixCls + '-next') }, React.createElement('a', null) ), React.createElement(Options, { rootPrefixCls: prefixCls, selectComponentClass: props.selectComponentClass, selectPrefixCls: props.selectPrefixCls, changeSize: this.props.showSizeChanger ? this._changePageSize.bind(this) : null, current: this.state.current, quickGo: this.props.showQuickJumper ? this._handleChange.bind(this) : null }) ); } }, { key: '_calcPage', // private methods value: function _calcPage(pageSize) { if (typeof pageSize === 'undefined') { pageSize = this.state.pageSize; } return Math.floor((this.props.total - 1) / pageSize) + 1; } }, { key: '_isValid', value: function _isValid(page) { return typeof page === 'number' && page >= 1 && page !== this.state.current; } }, { key: '_handleKeyDown', value: function _handleKeyDown(evt) { if (evt.keyCode === KEYCODE.ARROW_UP || evt.keyCode === KEYCODE.ARROW_DOWN) { evt.preventDefault(); } } }, { key: '_handleKeyUp', value: function _handleKeyUp(evt) { var _val = evt.target.value; var val = undefined; if (_val === '') { val = _val; } else if (isNaN(Number(_val))) { val = this.state._current; } else { val = Number(_val); } this.setState({ _current: val }); if (evt.keyCode === KEYCODE.ENTER) { this._handleChange(val); } else if (evt.keyCode === KEYCODE.ARROW_UP) { this._handleChange(val - 1); } else if (evt.keyCode === KEYCODE.ARROW_DOWN) { this._handleChange(val + 1); } } }, { key: '_changePageSize', value: function _changePageSize(size) { if (typeof size === 'number') { var current = this.state.current; this.setState({ pageSize: size }); if (this.state.current > this._calcPage(size)) { current = this._calcPage(size); this.setState({ current: current, _current: current }); } this.props.onShowSizeChange(current, size); } } }, { key: '_handleChange', value: function _handleChange(page) { if (this._isValid(page)) { if (page > this._calcPage()) { page = this._calcPage(); } this.setState({ current: page, _current: page }); this.props.onChange(page); return page; } return this.state.current; } }, { key: '_prev', value: function _prev() { if (this._hasPrev()) { this._handleChange(this.state.current - 1); } } }, { key: '_next', value: function _next() { if (this._hasNext()) { this._handleChange(this.state.current + 1); } } }, { key: '_jumpPrev', value: function _jumpPrev() { this._handleChange(Math.max(1, this.state.current - 5)); } }, { key: '_jumpNext', value: function _jumpNext() { this._handleChange(Math.min(this._calcPage(), this.state.current + 5)); } }, { key: '_hasPrev', value: function _hasPrev() { return this.state.current > 1; } }, { key: '_hasNext', value: function _hasNext() { return this.state.current < this._calcPage(); } }]); return Pagination; })(React.Component); Pagination.propTypes = { current: React.PropTypes.number, total: React.PropTypes.number, pageSize: React.PropTypes.number, onChange: React.PropTypes.func, showSizeChanger: React.PropTypes.bool, onShowSizeChange: React.PropTypes.func, selectComponentClass: React.PropTypes.func, showQuickJumper: React.PropTypes.bool }; Pagination.defaultProps = { current: 1, total: 0, pageSize: 10, onChange: noop, className: '', selectPrefixCls: 'rc-select', prefixCls: 'rc-pagination', selectComponentClass: null, showQuickJumper: false, showSizeChanger: false, onShowSizeChange: noop }; module.exports = Pagination; /***/ }, /* 254 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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) subClass.__proto__ = superClass; } var React = __webpack_require__(76); var Pager = (function (_React$Component) { _inherits(Pager, _React$Component); function Pager() { _classCallCheck(this, Pager); _get(Object.getPrototypeOf(Pager.prototype), 'constructor', this).apply(this, arguments); } _createClass(Pager, [{ key: 'render', value: function render() { var props = this.props; var prefixCls = props.rootPrefixCls + '-item'; var cls = prefixCls + ' ' + prefixCls + '-' + props.page; if (props.active) { cls = cls + ' ' + prefixCls + '-active'; } var title = props.page === 1 ? 'First Page' : props.last ? 'Last Page: ' + props.page : 'Page ' + props.page; return React.createElement( 'li', { title: title, className: cls, onClick: props.onClick }, React.createElement( 'a', null, props.page ) ); } }]); return Pager; })(React.Component); Pager.propTypes = { page: React.PropTypes.number, active: React.PropTypes.bool, last: React.PropTypes.bool }; module.exports = Pager; /***/ }, /* 255 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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) subClass.__proto__ = superClass; } var React = __webpack_require__(76); var KEYCODE = __webpack_require__(256); var Options = (function (_React$Component) { _inherits(Options, _React$Component); function Options(props) { var _this = this; _classCallCheck(this, Options); _get(Object.getPrototypeOf(Options.prototype), 'constructor', this).call(this, props); this.state = { current: props.current, _current: props.current }; ['_handleChange', '_changeSize', '_go'].forEach(function (method) { return _this[method] = _this[method].bind(_this); }); } _createClass(Options, [{ key: 'render', value: function render() { var props = this.props; var state = this.state; var prefixCls = props.rootPrefixCls + '-options'; var changeSize = props.changeSize; var quickGo = props.quickGo; var Select = props.selectComponentClass; var changeSelect = null; var goInput = null; if (!(changeSize || quickGo)) { return null; } if (changeSize && Select) { var _Option = Select.Option; changeSelect = React.createElement( Select, { prefixCls: props.selectPrefixCls, showSearch: false, className: prefixCls + '-size-changer', optionLabelProp: 'children', defaultValue: '10', onChange: this._changeSize }, React.createElement( _Option, { value: '10' }, '10 条/页' ), React.createElement( _Option, { value: '20' }, '20 条/页' ), React.createElement( _Option, { value: '30' }, '30 条/页' ), React.createElement( _Option, { value: '40' }, '40 条/页' ) ); } if (quickGo) { goInput = React.createElement( 'div', { title: 'Quick jump to page', className: prefixCls + '-quick-jumper' }, '跳至', React.createElement('input', { type: 'text', value: state._current, onChange: this._handleChange.bind(this), onKeyUp: this._go.bind(this) }), '页' ); } return React.createElement( 'div', { className: '' + prefixCls }, changeSelect, goInput ); } }, { key: '_changeSize', value: function _changeSize(value) { this.props.changeSize(Number(value)); } }, { key: '_handleChange', value: function _handleChange(evt) { var _val = evt.target.value; this.setState({ _current: _val }); } }, { key: '_go', value: function _go(e) { var _val = e.target.value; if (_val === '') { return; } var val = Number(this.state._current); if (isNaN(val)) { val = this.state.current; } if (e.keyCode === KEYCODE.ENTER) { var c = this.props.quickGo(val); this.setState({ _current: c, current: c }); } } }]); return Options; })(React.Component); Options.propTypes = { changeSize: React.PropTypes.func, quickGo: React.PropTypes.func, selectComponentClass: React.PropTypes.func, current: React.PropTypes.number }; module.exports = Options; /***/ }, /* 256 */ /***/ function(module, exports) { 'use strict'; module.exports = { ZERO: 48, NINE: 57, NUMPAD_ZERO: 96, NUMPAD_NINE: 105, BACKSPACE: 8, DELETE: 46, ENTER: 13, ARROW_UP: 38, ARROW_DOWN: 40 }; /***/ }, /* 257 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcSteps = __webpack_require__(258); var _rcSteps2 = _interopRequireDefault(_rcSteps); var AntSteps = _react2['default'].createClass({ displayName: 'AntSteps', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-steps', iconPrefix: 'ant', size: 'default', maxDescriptionWidth: 100, current: 0 }; }, render: function render() { var maxDescriptionWidth = this.props.maxDescriptionWidth; if (this.props.direction === 'vertical') { maxDescriptionWidth = 'auto'; } return _react2['default'].createElement( _rcSteps2['default'], { size: this.props.size, current: this.props.current, direction: this.props.direction, iconPrefix: this.props.iconPrefix, maxDescriptionWidth: maxDescriptionWidth, prefixCls: this.props.prefixCls }, this.props.children ); } }); AntSteps.Step = _rcSteps2['default'].Step; exports['default'] = AntSteps; module.exports = exports['default']; /***/ }, /* 258 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var Steps = __webpack_require__(259); Steps.Step = __webpack_require__(260); module.exports = Steps; /***/ }, /* 259 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var React = __webpack_require__(76); var Steps = React.createClass({ displayName: 'Steps', _previousStepsWidth: 0, _itemsWidth: [], getInitialState: function getInitialState() { return { init: false, tailWidth: 0 }; }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-steps', iconPrefix: 'rc', maxDescriptionWidth: 120, direction: '', current: 0 }; }, componentDidMount: function componentDidMount() { if (this.props.direction === 'vertical') { return; } var $dom = React.findDOMNode(this); var len = $dom.children.length - 1; var i; this._itemsWidth = new Array(len + 1); for (i = 0; i <= len - 1; i++) { var $item = $dom.children[i].children; this._itemsWidth[i] = Math.ceil($item[0].offsetWidth + $item[1].children[0].offsetWidth); } this._itemsWidth[i] = Math.ceil($dom.children[len].offsetWidth); this._previousStepsWidth = Math.floor(React.findDOMNode(this).offsetWidth); this._update(); /* * 把最后一个元素设置为absolute,是为了防止动态添加元素后滚动条出现导致的布局问题。 * 未来不考虑ie8一类的浏览器后,会采用纯css来避免各种问题。 */ $dom.children[len].style.position = 'absolute'; /* * 下面的代码是为了兼容window系统下滚动条出现后会占用宽度的问题。 * componentDidMount时滚动条还不一定出现了,这时候获取的宽度可能不是最终宽度。 * 对于滚动条不占用宽度的浏览器,下面的代码也不二次render,_resize里面会判断要不要更新。 */ var me = this; setTimeout(function () { me._resize(); }); if (window.attachEvent) { window.attachEvent('onresize', this._resize); } else { window.addEventListener('resize', this._resize); } }, componentWillUnmount: function componentWillUnmount() { if (this.props.direction === 'vertical') { return; } if (window.attachEvent) { window.detachEvent('onresize', this._resize); } else { window.removeEventListener('resize', this._resize); } }, componentDidUpdate: function componentDidUpdate() { this._resize(); }, _resize: function _resize() { var w = Math.floor(React.findDOMNode(this).offsetWidth); if (this._previousStepsWidth === w) { return; } this._previousStepsWidth = w; this._update(); }, _update: function _update() { var len = this.props.children.length - 1; var tw = 0; this._itemsWidth.forEach(function (w) { tw += w; }); var dw = Math.floor((this._previousStepsWidth - tw) / len) - 1; if (dw <= 0) { return; } this.setState({ init: true, tailWidth: dw }); }, render: function render() { var props = this.props; var prefixCls = props.prefixCls; var children = props.children; var maxDescriptionWidth = props.maxDescriptionWidth; var iconPrefix = props.iconPrefix; var len = children.length - 1; var iws = this._itemsWidth; var clsName = prefixCls; clsName += props.size === 'small' ? ' ' + prefixCls + '-small' : ''; clsName += props.direction === 'vertical' ? ' ' + prefixCls + '-vertical' : ''; return React.createElement( 'div', { className: clsName }, React.Children.map(children, function (ele, idx) { var np = { stepNumber: (idx + 1).toString(), stepLast: idx === len, tailWidth: iws.length === 0 || idx === len ? 'auto' : iws[idx] + this.state.tailWidth, prefixCls: prefixCls, iconPrefix: iconPrefix, maxDescriptionWidth: maxDescriptionWidth }; if (!ele.props.status) { np.status = idx === props.current ? 'process' : idx < props.current ? 'finish' : 'wait'; } return React.cloneElement(ele, np); }, this) ); } }); module.exports = Steps; /***/ }, /* 260 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var React = __webpack_require__(76); var Step = React.createClass({ displayName: 'Step', render: function render() { var props = this.props; var status = props.status || 'wait'; var prefixCls = props.prefixCls; var iconPrefix = props.iconPrefix; var maxWidth = props.maxDescriptionWidth; var iconName = props.icon ? props.icon : 'check'; var icon = !props.icon && status !== 'finish' ? React.createElement( 'span', { className: prefixCls + '-icon' }, props.stepNumber ) : React.createElement('span', { className: prefixCls + '-icon ' + iconPrefix + 'icon ' + iconPrefix + 'icon-' + iconName }); return React.createElement( 'div', { className: prefixCls + '-item ' + (props.stepLast ? prefixCls + '-item-last ' : '') + prefixCls + '-status-' + status + (props.icon ? ' ' + prefixCls + '-custom' : ''), style: { width: props.tailWidth } }, !props.stepLast ? React.createElement( 'div', { className: prefixCls + '-tail' }, React.createElement('i', null) ) : '', React.createElement( 'div', { className: prefixCls + '-head' }, React.createElement( 'div', { className: prefixCls + '-head-inner' }, icon ) ), React.createElement( 'div', { className: prefixCls + '-main', style: { maxWidth: maxWidth } }, React.createElement( 'div', { className: prefixCls + '-title' }, props.title ), props.description ? React.createElement( 'div', { className: prefixCls + '-description' }, props.description ) : '' ) ); } }); module.exports = Step; /***/ }, /* 261 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rcInputNumber = __webpack_require__(262); var _rcInputNumber2 = _interopRequireDefault(_rcInputNumber); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); exports['default'] = _react2['default'].createClass({ displayName: 'index', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-input-number' }; }, render: function render() { var sizeClass = ''; if (this.props.size === 'large') { sizeClass = 'ant-input-number-lg'; } else if (this.props.size === 'small') { sizeClass = 'ant-input-number-sm'; } return _react2['default'].createElement(_rcInputNumber2['default'], _extends({ className: sizeClass, style: { width: 90 } }, this.props)); } }); module.exports = exports['default']; /***/ }, /* 262 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(263); /***/ }, /* 263 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var React = __webpack_require__(76); var rcUtil = __webpack_require__(77); function noop() {} function isValueNumber(value) { return (/^-?\d+?$/.test(value + '') ); } function preventDefault(e) { e.preventDefault(); } var InputNumber = React.createClass({ displayName: 'InputNumber', propTypes: { onChange: React.PropTypes.func }, getInitialState: function getInitialState() { var value = undefined; var props = this.props; if ('value' in props) { value = props.value; } else { value = props.defaultValue; } return { value: value, focused: props.autoFocus }; }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-input-number', max: Infinity, min: -Infinity, style: {}, defaultValue: '', onChange: noop }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('value' in nextProps) { this.setState({ value: nextProps.value }); } }, onChange: function onChange(event) { var props = this.props; var val = event.target.value.trim(); if (!val) { this.setValue(val); } else if (isValueNumber(val)) { val = Number(val); if ('min' in props) { if (val < props.min) { return; } } if ('max' in props) { if (val > props.max) { return; } } this.setValue(val); } }, onKeyDown: function onKeyDown(e) { if (e.keyCode === 38) { this.up(e); } else if (e.keyCode === 40) { this.down(e); } }, onFocus: function onFocus() { this.setState({ focused: true }); }, onBlur: function onBlur() { this.setState({ focused: false }); }, render: function render() { var _rcUtil$classSet; var props = this.props; var prefixCls = props.prefixCls; var classes = rcUtil.classSet((_rcUtil$classSet = {}, _defineProperty(_rcUtil$classSet, prefixCls, true), _defineProperty(_rcUtil$classSet, props.className, !!props.className), _defineProperty(_rcUtil$classSet, prefixCls + '-disabled', props.disabled), _defineProperty(_rcUtil$classSet, prefixCls + '-focused', this.state.focused), _rcUtil$classSet)); var upDisabledClass = ''; var downDisabledClass = ''; var value = this.state.value; if (isValueNumber(value)) { var val = Number(value); if (val >= props.max) { upDisabledClass = prefixCls + '-handler-up-disabled'; } if (val <= props.min) { downDisabledClass = prefixCls + '-handler-up-disabled'; } } else { upDisabledClass = prefixCls + '-handler-up-disabled'; downDisabledClass = prefixCls + '-handler-up-disabled'; } // ref for test return React.createElement( 'div', { className: classes, style: props.style }, React.createElement( 'div', { className: prefixCls + '-handler-wrap' }, React.createElement( 'div', { unselectable: 'unselectable', ref: 'up', onClick: upDisabledClass ? noop : this.up, onMouseDown: preventDefault, className: prefixCls + '-handler ' + prefixCls + '-handler-up ' + upDisabledClass }, React.createElement('a', { unselectable: 'unselectable', className: prefixCls + '-handler-up-inner', href: '#', onClick: preventDefault }) ), React.createElement( 'div', { unselectable: 'unselectable', ref: 'down', onMouseDown: preventDefault, onClick: downDisabledClass ? noop : this.down, className: prefixCls + '-handler ' + prefixCls + '-handler-down ' + downDisabledClass }, React.createElement('a', { unselectable: 'unselectable', className: prefixCls + '-handler-down-inner', href: '#', onClick: preventDefault }) ) ), React.createElement( 'div', { className: prefixCls + '-input-wrap' }, React.createElement('input', { className: prefixCls + '-input', autoComplete: 'off', onFocus: this.onFocus, onBlur: this.onBlur, onKeyDown: this.onKeyDown, autoFocus: props.autoFocus, readOnly: props.readOnly, disabled: props.disabled, max: props.max, min: props.min, name: props.name, onChange: this.onChange, ref: 'input', value: this.state.value }) ) ); }, setValue: function setValue(v, callback) { this.setState({ value: v }, callback); this.props.onChange(v); }, step: function step(type, e) { var _this = this; if (e) { e.preventDefault(); } var props = this.props; if (props.disabled) { return; } var value = this.state.value; if (isNaN(value)) { return; } var stepNum = props.step || 1; var val = value; if (type === 'down') { val -= stepNum; } else if (type === 'up') { val += stepNum; } if (val > props.max || val < props.min) { return; } this.setValue(val, function () { React.findDOMNode(_this.refs.input).focus(); }); }, down: function down(e) { this.step('down', e); }, up: function up(e) { this.step('up', e); } }); module.exports = InputNumber; /***/ }, /* 264 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rcSwitch = __webpack_require__(265); var _rcSwitch2 = _interopRequireDefault(_rcSwitch); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); exports['default'] = _react2['default'].createClass({ displayName: 'index', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-switch' }; }, render: function render() { return _react2['default'].createElement(_rcSwitch2['default'], this.props); } }); module.exports = exports['default']; /***/ }, /* 265 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(266); /***/ }, /* 266 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var React = __webpack_require__(76); var rcUtil = __webpack_require__(77); function noop() {} var Switch = React.createClass({ displayName: 'Switch', getInitialState: function getInitialState() { var props = this.props; var checked = false; if ('checked' in props) { checked = !!props.checked; } else { checked = !!props.defaultChecked; } return { checked: checked }; }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-switch', style: {}, checkedChildren: null, unCheckedChildren: null, className: '', defaultChecked: false, onChange: noop }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('checked' in nextProps) { this.setState({ checked: !!nextProps.checked }); } }, render: function render() { var _rcUtil$classSet; var props = this.props; var prefixCls = props.prefixCls; return React.createElement( 'span', { className: rcUtil.classSet((_rcUtil$classSet = {}, _defineProperty(_rcUtil$classSet, props.className, !!props.className), _defineProperty(_rcUtil$classSet, prefixCls, 1), _defineProperty(_rcUtil$classSet, prefixCls + '-checked', this.state.checked), _defineProperty(_rcUtil$classSet, prefixCls + '-disabled', props.disabled), _rcUtil$classSet)), onClick: props.disabled ? noop : this.toggle, style: props.style }, React.createElement( 'span', { className: prefixCls + '-inner' }, this.state.checked ? props.checkedChildren : props.unCheckedChildren ) ); }, toggle: function toggle() { var checked = !this.state.checked; this.setState({ checked: checked }); this.props.onChange(checked); } }); module.exports = Switch; /***/ }, /* 267 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rcCheckbox = __webpack_require__(268); var _rcCheckbox2 = _interopRequireDefault(_rcCheckbox); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); exports['default'] = _react2['default'].createClass({ displayName: 'index', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-checkbox' }; }, render: function render() { return _react2['default'].createElement(_rcCheckbox2['default'], this.props); } }); module.exports = exports['default']; /***/ }, /* 268 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(269); /***/ }, /* 269 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _classnames2 = __webpack_require__(270); var _classnames3 = _interopRequireDefault(_classnames2); var Checkbox = (function (_React$Component) { _inherits(Checkbox, _React$Component); function Checkbox(props) { _classCallCheck(this, Checkbox); _get(Object.getPrototypeOf(Checkbox.prototype), 'constructor', this).call(this, props); this.handleChange = this.handleChange.bind(this); var checked = false; if ('checked' in props) { checked = props.checked; } else { checked = props.defaultChecked; } this.state = { checked: checked }; } _createClass(Checkbox, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { if ('checked' in nextProps) { this.setState({ checked: nextProps.checked }); } } }, { key: 'render', value: function render() { var _classnames; var props = this.props; var prefixCls = props.prefixCls; var checked = this.state.checked; if (typeof checked === 'boolean') { checked = checked ? 1 : 0; } return _react2['default'].createElement( 'span', { className: (0, _classnames3['default'])((_classnames = {}, _defineProperty(_classnames, props.className, !!props.className), _defineProperty(_classnames, prefixCls, 1), _defineProperty(_classnames, prefixCls + '-checked', checked), _defineProperty(_classnames, prefixCls + '-checked-' + checked, !!checked), _defineProperty(_classnames, prefixCls + '-disabled', props.disabled), _classnames)), style: props.style }, _react2['default'].createElement('span', { className: prefixCls + '-inner' }), _react2['default'].createElement('input', _extends({}, props, { defaultChecked: !!props.defaultChecked, className: prefixCls + '-input', checked: !!checked, onChange: this.handleChange })) ); } }, { key: 'handleChange', value: function handleChange(e) { var checked = e.target.checked; if (!('checked' in this.props)) { this.setState({ checked: checked ? 1 : 0 }); } this.props.onChange(e, this.state.checked); } }]); return Checkbox; })(_react2['default'].Component); exports['default'] = Checkbox; Checkbox.propTypes = { prefixCls: _react2['default'].PropTypes.string, style: _react2['default'].PropTypes.object, type: _react2['default'].PropTypes.string, className: _react2['default'].PropTypes.string, defaultChecked: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.number, _react2['default'].PropTypes.bool]), checked: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.number, _react2['default'].PropTypes.bool]), onChange: _react2['default'].PropTypes.func }; Checkbox.defaultProps = { prefixCls: 'rc-checkbox', style: {}, type: 'checkbox', className: '', defaultChecked: 0, onChange: function onChange() {} }; module.exports = exports['default']; /***/ }, /* 270 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/*! Copyright (c) 2015 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ /* global define */ (function () { 'use strict'; var hasOwn = {}.hasOwnProperty; function classNames () { var classes = ''; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (!arg) continue; var argType = typeof arg; if (argType === 'string' || argType === 'number') { classes += ' ' + arg; } else if (Array.isArray(arg)) { classes += ' ' + classNames.apply(null, arg); } else if (argType === 'object') { for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes += ' ' + key; } } } } return classes.substr(1); } if (typeof module !== 'undefined' && module.exports) { module.exports = classNames; } else if (true) { // register as 'classnames', consistent with npm package name !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { return classNames; }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else { window.classNames = classNames; } }()); /***/ }, /* 271 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _reqwestWithoutXhr2 = __webpack_require__(272); var _reqwestWithoutXhr22 = _interopRequireDefault(_reqwestWithoutXhr2); var _rcTable = __webpack_require__(273); var _rcTable2 = _interopRequireDefault(_rcTable); var _checkbox = __webpack_require__(267); var _checkbox2 = _interopRequireDefault(_checkbox); var _filterDropdown = __webpack_require__(276); var _filterDropdown2 = _interopRequireDefault(_filterDropdown); var _pagination = __webpack_require__(251); var _pagination2 = _interopRequireDefault(_pagination); var _objectAssign2 = __webpack_require__(184); var _objectAssign3 = _interopRequireDefault(_objectAssign2); function noop() {} function defaultResolve(data) { return data || []; } var DataSource = (function () { _createClass(DataSource, [{ key: 'init', value: function init(config) { this.config = config; this.url = config.url || ''; this.resolve = config.resolve || defaultResolve; this.getParams = config.getParams || noop; this.getPagination = config.getPagination || noop; this.headers = config.headers || {}; this.data = config.data || {}; } }]); function DataSource(config) { _classCallCheck(this, DataSource); if (config) { this.init(config); } } _createClass(DataSource, [{ key: 'clone', value: function clone() { var config = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; return new DataSource((0, _objectAssign3['default'])({}, this.config, config)); } }]); return DataSource; })(); var AntTable = _react2['default'].createClass({ displayName: 'AntTable', getInitialState: function getInitialState() { return { // 减少状态 selectedRowKeys: [], // only for remote data: [], dataSource: this.props.dataSource, filters: {}, loading: false, sortColumn: '', sortOrder: '', sorter: null, pagination: this.hasPagination() ? (0, _objectAssign3['default'])({ pageSize: 10, current: 1 }, this.props.pagination) : {} }; }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-table', useFixedHeader: false, rowSelection: null, size: 'normal', bordered: false }; }, propTypes: { dataSource: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.array, _react2['default'].PropTypes.instanceOf(DataSource)]) }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('pagination' in nextProps && nextProps.pagination !== false) { this.setState({ pagination: (0, _objectAssign3['default'])({}, this.state.pagination, nextProps.pagination) }); } // 外界只有 dataSource 的变化会触发新请求 if ('dataSource' in nextProps && nextProps.dataSource !== this.props.dataSource) { this.setState({ selectedRowKeys: [], dataSource: nextProps.dataSource, loading: true }, this.fetch); } if (nextProps.columns !== this.props.columns) { this.setState({ filters: {} }); } }, hasPagination: function hasPagination(pagination) { if (pagination === undefined) { pagination = this.props.pagination; } return pagination !== false; }, isLocalDataSource: function isLocalDataSource() { return Array.isArray(this.state.dataSource); }, getRemoteDataSource: function getRemoteDataSource() { return this.state.dataSource; }, toggleSortOrder: function toggleSortOrder(order, column) { var sortColumn = this.state.sortColumn; var sortOrder = this.state.sortOrder; var sorter = undefined; // 只同时允许一列进行排序,否则会导致排序顺序的逻辑问题 var isSortColumn = this.isSortColumn(column); if (!isSortColumn) { // 当前列未排序 sortOrder = order; sortColumn = column; } else { // 当前列已排序 if (sortOrder === order) { // 切换为未排序状态 sortOrder = ''; sortColumn = null; } else { // 切换为排序状态 sortOrder = order; } } if (this.isLocalDataSource()) { sorter = function () { var result = column.sorter.apply(this, arguments); if (sortOrder === 'ascend') { return result; } else if (sortOrder === 'descend') { return -result; } }; } this.fetch({ sortOrder: sortOrder, sortColumn: sortColumn, sorter: sorter }); }, handleFilter: function handleFilter(column, filters) { filters = (0, _objectAssign3['default'])({}, this.state.filters, _defineProperty({}, this.getColumnKey(column), filters)); this.fetch({ selectedRowKeys: [], filters: filters }); }, handleSelect: function handleSelect(record, rowIndex, e) { var _this = this; var checked = e.target.checked; var selectedRowKeys = this.state.selectedRowKeys.concat(); var key = this.getRecordKey(record, rowIndex); if (checked) { selectedRowKeys.push(this.getRecordKey(record, rowIndex)); } else { selectedRowKeys = selectedRowKeys.filter(function (i) { return key !== i; }); } this.setState({ selectedRowKeys: selectedRowKeys }); if (this.props.rowSelection.onSelect) { var data = this.getCurrentPageData(); var selectedRows = data.filter(function (row, i) { return selectedRowKeys.indexOf(_this.getRecordKey(row, i)) >= 0; }); this.props.rowSelection.onSelect(record, checked, selectedRows); } }, handleSelectAllRow: function handleSelectAllRow(e) { var _this2 = this; var checked = e.target.checked; var data = this.getCurrentPageData(); var selectedRowKeys = checked ? data.map(function (item, i) { return _this2.getRecordKey(item, i); }) : []; this.setState({ selectedRowKeys: selectedRowKeys }); if (this.props.rowSelection.onSelectAll) { var selectedRows = data.filter(function (row, i) { return selectedRowKeys.indexOf(_this2.getRecordKey(row, i)) >= 0; }); this.props.rowSelection.onSelectAll(checked, selectedRows); } }, handlePageChange: function handlePageChange(current) { var pagination = (0, _objectAssign3['default'])({}, this.state.pagination); if (current) { pagination.current = current; } else { pagination.current = pagination.current || 1; } this.fetch({ // 防止内存泄漏,只维持当页 selectedRowKeys: [], pagination: pagination }); }, renderSelectionCheckBox: function renderSelectionCheckBox(value, record, index) { var rowIndex = this.getRecordKey(record, index); // 从 1 开始 var checked = this.state.selectedRowKeys.indexOf(rowIndex) >= 0; return _react2['default'].createElement(_checkbox2['default'], { checked: checked, onChange: this.handleSelect.bind(this, record, rowIndex) }); }, getRecordKey: function getRecordKey(record, index) { return record.key || index; }, renderRowSelection: function renderRowSelection() { var _this3 = this; var columns = this.props.columns.concat(); if (this.props.rowSelection) { var data = this.getCurrentPageData(); var checked = undefined; if (!data.length) { checked = false; } else { checked = data.every(function (item, i) { var key = _this3.getRecordKey(item, i); return _this3.state.selectedRowKeys.indexOf(key) >= 0; }); } var checkboxAll = _react2['default'].createElement(_checkbox2['default'], { checked: checked, onChange: this.handleSelectAllRow }); var selectionColumn = { key: 'selection-column', title: checkboxAll, width: 60, render: this.renderSelectionCheckBox, className: 'ant-table-selection-column' }; if (columns[0] && columns[0].key === 'selection-column') { columns[0] = selectionColumn; } else { columns.unshift(selectionColumn); } } return columns; }, getCurrentPageData: function getCurrentPageData() { return this.isLocalDataSource() ? this.getLocalDataPaging() : this.state.data; }, getColumnKey: function getColumnKey(column, index) { return column.key || column.dataIndex || index; }, isSortColumn: function isSortColumn(column) { if (!column || !this.state.sortColumn) { return false; } var colKey = this.getColumnKey(column); var isSortColumn = this.getColumnKey(this.state.sortColumn) === colKey; return isSortColumn; }, renderColumnsDropdown: function renderColumnsDropdown(columns) { var _this4 = this; return columns.map(function (column, i) { column = (0, _objectAssign3['default'])({}, column); var key = _this4.getColumnKey(column, i); var filterDropdown = undefined, sortButton = undefined; if (column.filters && column.filters.length > 0) { var colFilters = _this4.state.filters[key] || []; filterDropdown = _react2['default'].createElement(_filterDropdown2['default'], { column: column, selectedKeys: colFilters, confirmFilter: _this4.handleFilter }); } if (column.sorter) { var isSortColumn = _this4.isSortColumn(column); if (isSortColumn) { column.className = column.className || ''; if (_this4.state.sortOrder) { column.className += ' ant-table-column-sort'; } } sortButton = _react2['default'].createElement( 'div', { className: 'ant-table-column-sorter' }, _react2['default'].createElement( 'span', { className: 'ant-table-column-sorter-up ' + (isSortColumn && _this4.state.sortOrder === 'ascend' ? 'on' : 'off'), title: '升序排序', onClick: _this4.toggleSortOrder.bind(_this4, 'ascend', column) }, _react2['default'].createElement('i', { className: 'anticon anticon-caret-up' }) ), _react2['default'].createElement( 'span', { className: 'ant-table-column-sorter-down ' + (isSortColumn && _this4.state.sortOrder === 'descend' ? 'on' : 'off'), title: '降序排序', onClick: _this4.toggleSortOrder.bind(_this4, 'descend', column) }, _react2['default'].createElement('i', { className: 'anticon anticon-caret-down' }) ) ); } column.title = _react2['default'].createElement( 'div', null, column.title, sortButton, filterDropdown ); return column; }); }, handleShowSizeChange: function handleShowSizeChange(current, pageSize) { var pagination = (0, _objectAssign3['default'])(this.state.pagination, { pageSize: pageSize }); this.fetch({ pagination: pagination }); }, renderPagination: function renderPagination() { // 强制不需要分页 if (!this.hasPagination()) { return null; } var classString = 'ant-table-pagination'; if (this.props.size === 'small') { classString += ' mini'; } var total = this.state.pagination.total; if (!total && this.isLocalDataSource()) { total = this.getLocalData().length; } return total > 0 ? _react2['default'].createElement(_pagination2['default'], _extends({ className: classString, onChange: this.handlePageChange, total: total, pageSize: 10, onShowSizeChange: this.handleShowSizeChange }, this.state.pagination)) : null; }, prepareParamsArguments: function prepareParamsArguments(state) { var _this5 = this; // 准备筛选、排序、分页的参数 var pagination = undefined; var filters = {}; var sorter = {}; pagination = state.pagination; this.props.columns.forEach(function (column) { var colFilters = state.filters[_this5.getColumnKey(column)] || []; if (colFilters.length > 0) { filters[_this5.getColumnKey(column)] = colFilters; } }); if (state.sortColumn && state.sortOrder && state.sortColumn.dataIndex) { sorter.field = state.sortColumn.dataIndex; sorter.order = state.sortOrder; } return [pagination, filters, sorter]; }, fetch: function fetch(newState) { var _this6 = this; if (this.isLocalDataSource()) { if (newState) { this.setState(newState); } } else { var _ret = (function () { var state = (0, _objectAssign3['default'])({}, _this6.state, newState); if (newState || !_this6.state.loading) { _this6.setState((0, _objectAssign3['default'])({ loading: true }, newState)); } // remote 模式使用 this.dataSource var dataSource = _this6.getRemoteDataSource(); var buildInParams = dataSource.getParams.apply(_this6, _this6.prepareParamsArguments(state)) || {}; return { v: (0, _reqwestWithoutXhr22['default'])({ url: dataSource.url, method: 'get', data: (0, _objectAssign3['default'])(buildInParams, dataSource.data), headers: dataSource.headers, type: 'json', success: function success(result) { if (_this6.isMounted()) { var pagination = (0, _objectAssign3['default'])(state.pagination, dataSource.getPagination.call(_this6, result)); _this6.setState({ loading: false, data: dataSource.resolve.call(_this6, result), pagination: pagination }); } }, error: function error() { _this6.setState({ loading: false, data: [] }); } }) }; })(); if (typeof _ret === 'object') return _ret.v; } }, findColumn: function findColumn(myKey) { var _this7 = this; return this.props.columns.filter(function (c) { return _this7.getColumnKey(c) === myKey; })[0]; }, getLocalDataPaging: function getLocalDataPaging() { var data = this.getLocalData(); var current = undefined, pageSize = undefined; var state = this.state; // 如果没有分页的话,默认全部展示 if (!this.hasPagination()) { pageSize = Number.MAX_VALUE; current = 1; } else { pageSize = state.pagination.pageSize; current = state.pagination.current; } // 分页 // --- // 当数据量少于每页数量时,直接设置数据 // 否则进行读取分页数据 if (data.length > pageSize || pageSize === Number.MAX_VALUE) { data = data.filter(function (item, i) { if (i >= (current - 1) * pageSize && i < current * pageSize) { return item; } }); } return data; }, getLocalData: function getLocalData() { var _this8 = this; var state = this.state; var data = this.state.dataSource; // 排序 if (state.sortOrder && state.sorter) { data = data.sort(state.sorter); } // 筛选 if (state.filters) { Object.keys(state.filters).forEach(function (columnKey) { var col = _this8.findColumn(columnKey); var values = state.filters[columnKey] || []; if (values.length === 0) { return; } data = data.filter(function (record) { return values.some(function (v) { return col.onFilter(v, record); }); }); }); } return data; }, componentDidMount: function componentDidMount() { if (!this.isLocalDataSource()) { this.fetch(); } }, render: function render() { var data = this.getCurrentPageData(); var columns = this.renderRowSelection(); var classString = ''; var expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false; if (this.state.loading && !this.isLocalDataSource()) { classString += ' ant-table-loading'; } if (this.props.size === 'small') { classString += ' ant-table-small'; } if (this.props.bordered) { classString += ' ant-table-bordered'; } columns = this.renderColumnsDropdown(columns); columns = columns.map(function (column, i) { column.key = column.dataIndex || i; return column; }); var emptyText = undefined; var emptyClass = ''; if (!data || data.length === 0) { emptyText = _react2['default'].createElement( 'div', { className: 'ant-table-placeholder' }, _react2['default'].createElement('i', { className: 'anticon anticon-frown' }), '暂无数据' ); emptyClass = ' ant-table-empty'; } return _react2['default'].createElement( 'div', { className: 'clearfix' + emptyClass }, _react2['default'].createElement(_rcTable2['default'], _extends({}, this.props, { data: data, columns: columns, className: classString, expandIconAsCell: expandIconAsCell })), emptyText, this.renderPagination() ); } }); AntTable.DataSource = DataSource; exports['default'] = AntTable; module.exports = exports['default']; /***/ }, /* 272 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! * Reqwest! A general purpose XHR connection manager * license MIT (c) Dustin Diaz 2015 * https://github.com/ded/reqwest */ !function (name, context, definition) { if (typeof module != 'undefined' && module.exports) module.exports = definition() else if (true) !(__WEBPACK_AMD_DEFINE_FACTORY__ = (definition), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) else context[name] = definition() }('reqwest', this, function () { var context = this var doc = document , byTag = 'getElementsByTagName' , head = doc[byTag]('head')[0] var httpsRe = /^http/ , protocolRe = /(^\w+):\/\// , twoHundo = /^(20\d|1223)$/ //http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request , readyState = 'readyState' , contentType = 'Content-Type' , requestedWith = 'X-Requested-With' , uniqid = 0 , callbackPrefix = 'reqwest_' + (+new Date()) , lastValue // data stored by the most recent JSONP callback , xmlHttpRequest = 'XMLHttpRequest' , xDomainRequest = 'XDomainRequest' , noop = function () {} , isArray = typeof Array.isArray == 'function' ? Array.isArray : function (a) { return a instanceof Array } , defaultHeaders = { 'contentType': 'application/x-www-form-urlencoded' , 'requestedWith': xmlHttpRequest , 'accept': { '*': 'text/javascript, text/html, application/xml, text/xml, */*' , 'xml': 'application/xml, text/xml' , 'html': 'text/html' , 'text': 'text/plain' , 'json': 'application/json, text/javascript' , 'js': 'application/javascript, text/javascript' } } , xhr = function(o) { // is it x-domain if (o['crossOrigin'] === true) { var xhr = context[xmlHttpRequest] ? new XMLHttpRequest() : null if (xhr && 'withCredentials' in xhr) { return xhr } else if (context[xDomainRequest]) { return new XDomainRequest() } else { throw new Error('Browser does not support cross-origin requests') } } else if (context[xmlHttpRequest]) { return new XMLHttpRequest() } else if (XHR2) { return new XHR2() } else { return new ActiveXObject('Microsoft.XMLHTTP') } } , globalSetupOptions = { dataFilter: function (data) { return data } } function succeed(r) { var protocol = protocolRe.exec(r.url) protocol = (protocol && protocol[1]) || context.location.protocol return httpsRe.test(protocol) ? twoHundo.test(r.request.status) : !!r.request.response } function handleReadyState(r, success, error) { return function () { // use _aborted to mitigate against IE err c00c023f // (can't read props on aborted request objects) if (r._aborted) return error(r.request) if (r._timedOut) return error(r.request, 'Request is aborted: timeout') if (r.request && r.request[readyState] == 4) { r.request.onreadystatechange = noop if (succeed(r)) success(r.request) else error(r.request) } } } function setHeaders(http, o) { var headers = o['headers'] || {} , h headers['Accept'] = headers['Accept'] || defaultHeaders['accept'][o['type']] || defaultHeaders['accept']['*'] var isAFormData = typeof FormData === 'function' && (o['data'] instanceof FormData); // breaks cross-origin requests with legacy browsers if (!o['crossOrigin'] && !headers[requestedWith]) headers[requestedWith] = defaultHeaders['requestedWith'] if (!headers[contentType] && !isAFormData) headers[contentType] = o['contentType'] || defaultHeaders['contentType'] for (h in headers) headers.hasOwnProperty(h) && 'setRequestHeader' in http && http.setRequestHeader(h, headers[h]) } function setCredentials(http, o) { if (typeof o['withCredentials'] !== 'undefined' && typeof http.withCredentials !== 'undefined') { http.withCredentials = !!o['withCredentials'] } } function generalCallback(data) { lastValue = data } function urlappend (url, s) { return url + (/\?/.test(url) ? '&' : '?') + s } function handleJsonp(o, fn, err, url) { var reqId = uniqid++ , cbkey = o['jsonpCallback'] || 'callback' // the 'callback' key , cbval = o['jsonpCallbackName'] || reqwest.getcallbackPrefix(reqId) , cbreg = new RegExp('((^|\\?|&)' + cbkey + ')=([^&]+)') , match = url.match(cbreg) , script = doc.createElement('script') , loaded = 0 , isIE10 = navigator.userAgent.indexOf('MSIE 10.0') !== -1 if (match) { if (match[3] === '?') { url = url.replace(cbreg, '$1=' + cbval) // wildcard callback func name } else { cbval = match[3] // provided callback func name } } else { url = urlappend(url, cbkey + '=' + cbval) // no callback details, add 'em } context[cbval] = generalCallback script.type = 'text/javascript' script.src = url script.async = true if (typeof script.onreadystatechange !== 'undefined' && !isIE10) { // need this for IE due to out-of-order onreadystatechange(), binding script // execution to an event listener gives us control over when the script // is executed. See http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html script.htmlFor = script.id = '_reqwest_' + reqId } script.onload = script.onreadystatechange = function () { if ((script[readyState] && script[readyState] !== 'complete' && script[readyState] !== 'loaded') || loaded) { return false } script.onload = script.onreadystatechange = null script.onclick && script.onclick() // Call the user callback with the last value stored and clean up values and scripts. fn(lastValue) lastValue = undefined head.removeChild(script) loaded = 1 } // Add the script to the DOM head head.appendChild(script) // Enable JSONP timeout return { abort: function () { script.onload = script.onreadystatechange = null err({}, 'Request is aborted: timeout', {}) lastValue = undefined head.removeChild(script) loaded = 1 } } } function getRequest(fn, err) { var o = this.o , method = (o['method'] || 'GET').toUpperCase() , url = typeof o === 'string' ? o : o['url'] // convert non-string objects to query-string form unless o['processData'] is false , data = (o['processData'] !== false && o['data'] && typeof o['data'] !== 'string') ? reqwest.toQueryString(o['data']) : (o['data'] || null) , http , sendWait = false // if we're working on a GET request and we have data then we should append // query string to end of URL and not post data if ((o['type'] == 'jsonp' || method == 'GET') && data) { url = urlappend(url, data) data = null } if (o['type'] == 'jsonp') return handleJsonp(o, fn, err, url) // get the xhr from the factory if passed // if the factory returns null, fall-back to ours http = (o.xhr && o.xhr(o)) || xhr(o) http.open(method, url, o['async'] === false ? false : true) setHeaders(http, o) setCredentials(http, o) if (context[xDomainRequest] && http instanceof context[xDomainRequest]) { http.onload = fn http.onerror = err // NOTE: see // http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/30ef3add-767c-4436-b8a9-f1ca19b4812e http.onprogress = function() {} sendWait = true } else { http.onreadystatechange = handleReadyState(this, fn, err) } o['before'] && o['before'](http) if (sendWait) { setTimeout(function () { http.send(data) }, 200) } else { http.send(data) } return http } function Reqwest(o, fn) { this.o = o this.fn = fn init.apply(this, arguments) } function setType(header) { // json, javascript, text/plain, text/html, xml if (header === null) return undefined; //In case of no content-type. if (header.match('json')) return 'json' if (header.match('javascript')) return 'js' if (header.match('text')) return 'html' if (header.match('xml')) return 'xml' } function init(o, fn) { this.url = typeof o == 'string' ? o : o['url'] this.timeout = null // whether request has been fulfilled for purpose // of tracking the Promises this._fulfilled = false // success handlers this._successHandler = function(){} this._fulfillmentHandlers = [] // error handlers this._errorHandlers = [] // complete (both success and fail) handlers this._completeHandlers = [] this._erred = false this._responseArgs = {} var self = this fn = fn || function () {} if (o['timeout']) { this.timeout = setTimeout(function () { timedOut() }, o['timeout']) } if (o['success']) { this._successHandler = function () { o['success'].apply(o, arguments) } } if (o['error']) { this._errorHandlers.push(function () { o['error'].apply(o, arguments) }) } if (o['complete']) { this._completeHandlers.push(function () { o['complete'].apply(o, arguments) }) } function complete (resp) { o['timeout'] && clearTimeout(self.timeout) self.timeout = null while (self._completeHandlers.length > 0) { self._completeHandlers.shift()(resp) } } function success (resp) { var type = o['type'] || resp && setType(resp.getResponseHeader('Content-Type')) // resp can be undefined in IE resp = (type !== 'jsonp') ? self.request : resp // use global data filter on response text var filteredResponse = globalSetupOptions.dataFilter(resp.responseText, type) , r = filteredResponse try { resp.responseText = r } catch (e) { // can't assign this in IE<=8, just ignore } if (r) { switch (type) { case 'json': try { resp = context.JSON ? context.JSON.parse(r) : eval('(' + r + ')') } catch (err) { return error(resp, 'Could not parse JSON in response', err) } break case 'js': resp = eval(r) break case 'html': resp = r break case 'xml': resp = resp.responseXML && resp.responseXML.parseError // IE trololo && resp.responseXML.parseError.errorCode && resp.responseXML.parseError.reason ? null : resp.responseXML break } } self._responseArgs.resp = resp self._fulfilled = true fn(resp) self._successHandler(resp) while (self._fulfillmentHandlers.length > 0) { resp = self._fulfillmentHandlers.shift()(resp) } complete(resp) } function timedOut() { self._timedOut = true self.request.abort() } function error(resp, msg, t) { resp = self.request self._responseArgs.resp = resp self._responseArgs.msg = msg self._responseArgs.t = t self._erred = true while (self._errorHandlers.length > 0) { self._errorHandlers.shift()(resp, msg, t) } complete(resp) } this.request = getRequest.call(this, success, error) } Reqwest.prototype = { abort: function () { this._aborted = true this.request.abort() } , retry: function () { init.call(this, this.o, this.fn) } /** * Small deviation from the Promises A CommonJs specification * http://wiki.commonjs.org/wiki/Promises/A */ /** * `then` will execute upon successful requests */ , then: function (success, fail) { success = success || function () {} fail = fail || function () {} if (this._fulfilled) { this._responseArgs.resp = success(this._responseArgs.resp) } else if (this._erred) { fail(this._responseArgs.resp, this._responseArgs.msg, this._responseArgs.t) } else { this._fulfillmentHandlers.push(success) this._errorHandlers.push(fail) } return this } /** * `always` will execute whether the request succeeds or fails */ , always: function (fn) { if (this._fulfilled || this._erred) { fn(this._responseArgs.resp) } else { this._completeHandlers.push(fn) } return this } /** * `fail` will execute when the request fails */ , fail: function (fn) { if (this._erred) { fn(this._responseArgs.resp, this._responseArgs.msg, this._responseArgs.t) } else { this._errorHandlers.push(fn) } return this } , 'catch': function (fn) { return this.fail(fn) } } function reqwest(o, fn) { return new Reqwest(o, fn) } // normalize newline variants according to spec -> CRLF function normalize(s) { return s ? s.replace(/\r?\n/g, '\r\n') : '' } function serial(el, cb) { var n = el.name , t = el.tagName.toLowerCase() , optCb = function (o) { // IE gives value="" even where there is no value attribute // 'specified' ref: http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-862529273 if (o && !o['disabled']) cb(n, normalize(o['attributes']['value'] && o['attributes']['value']['specified'] ? o['value'] : o['text'])) } , ch, ra, val, i // don't serialize elements that are disabled or without a name if (el.disabled || !n) return switch (t) { case 'input': if (!/reset|button|image|file/i.test(el.type)) { ch = /checkbox/i.test(el.type) ra = /radio/i.test(el.type) val = el.value // WebKit gives us "" instead of "on" if a checkbox has no value, so correct it here ;(!(ch || ra) || el.checked) && cb(n, normalize(ch && val === '' ? 'on' : val)) } break case 'textarea': cb(n, normalize(el.value)) break case 'select': if (el.type.toLowerCase() === 'select-one') { optCb(el.selectedIndex >= 0 ? el.options[el.selectedIndex] : null) } else { for (i = 0; el.length && i < el.length; i++) { el.options[i].selected && optCb(el.options[i]) } } break } } // collect up all form elements found from the passed argument elements all // the way down to child elements; pass a '<form>' or form fields. // called with 'this'=callback to use for serial() on each element function eachFormElement() { var cb = this , e, i , serializeSubtags = function (e, tags) { var i, j, fa for (i = 0; i < tags.length; i++) { fa = e[byTag](tags[i]) for (j = 0; j < fa.length; j++) serial(fa[j], cb) } } for (i = 0; i < arguments.length; i++) { e = arguments[i] if (/input|select|textarea/i.test(e.tagName)) serial(e, cb) serializeSubtags(e, [ 'input', 'select', 'textarea' ]) } } // standard query string style serialization function serializeQueryString() { return reqwest.toQueryString(reqwest.serializeArray.apply(null, arguments)) } // { 'name': 'value', ... } style serialization function serializeHash() { var hash = {} eachFormElement.apply(function (name, value) { if (name in hash) { hash[name] && !isArray(hash[name]) && (hash[name] = [hash[name]]) hash[name].push(value) } else hash[name] = value }, arguments) return hash } // [ { name: 'name', value: 'value' }, ... ] style serialization reqwest.serializeArray = function () { var arr = [] eachFormElement.apply(function (name, value) { arr.push({name: name, value: value}) }, arguments) return arr } reqwest.serialize = function () { if (arguments.length === 0) return '' var opt, fn , args = Array.prototype.slice.call(arguments, 0) opt = args.pop() opt && opt.nodeType && args.push(opt) && (opt = null) opt && (opt = opt.type) if (opt == 'map') fn = serializeHash else if (opt == 'array') fn = reqwest.serializeArray else fn = serializeQueryString return fn.apply(null, args) } reqwest.toQueryString = function (o, trad) { var prefix, i , traditional = trad || false , s = [] , enc = encodeURIComponent , add = function (key, value) { // If value is a function, invoke it and return its value value = ('function' === typeof value) ? value() : (value == null ? '' : value) s[s.length] = enc(key) + '=' + enc(value) } // If an array was passed in, assume that it is an array of form elements. if (isArray(o)) { for (i = 0; o && i < o.length; i++) add(o[i]['name'], o[i]['value']) } else { // If traditional, encode the "old" way (the way 1.3.2 or older // did it), otherwise encode params recursively. for (prefix in o) { if (o.hasOwnProperty(prefix)) buildParams(prefix, o[prefix], traditional, add) } } // spaces should be + according to spec return s.join('&').replace(/%20/g, '+') } function buildParams(prefix, obj, traditional, add) { var name, i, v , rbracket = /\[\]$/ if (isArray(obj)) { // Serialize array item. for (i = 0; obj && i < obj.length; i++) { v = obj[i] if (traditional || rbracket.test(prefix)) { // Treat each array item as a scalar. add(prefix, v) } else { buildParams(prefix + '[' + (typeof v === 'object' ? i : '') + ']', v, traditional, add) } } } else if (obj && obj.toString() === '[object Object]') { // Serialize object item. for (name in obj) { buildParams(prefix + '[' + name + ']', obj[name], traditional, add) } } else { // Serialize scalar item. add(prefix, obj) } } reqwest.getcallbackPrefix = function () { return callbackPrefix } // jQuery and Zepto compatibility, differences can be remapped here so you can call // .ajax.compat(options, callback) reqwest.compat = function (o, fn) { if (o) { o['type'] && (o['method'] = o['type']) && delete o['type'] o['dataType'] && (o['type'] = o['dataType']) o['jsonpCallback'] && (o['jsonpCallbackName'] = o['jsonpCallback']) && delete o['jsonpCallback'] o['jsonp'] && (o['jsonpCallback'] = o['jsonp']) } return new Reqwest(o, fn) } reqwest.ajaxSetup = function (options) { options = options || {} for (var k in options) { globalSetupOptions[k] = options[k] } } return reqwest }); /***/ }, /* 273 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(274); /***/ }, /* 274 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _TableRow = __webpack_require__(275); var _TableRow2 = _interopRequireDefault(_TableRow); var Table = _react2['default'].createClass({ displayName: 'Table', propTypes: { data: _react2['default'].PropTypes.array, expandIconAsCell: _react2['default'].PropTypes.bool, useFixedHeader: _react2['default'].PropTypes.bool, columns: _react2['default'].PropTypes.array, prefixCls: _react2['default'].PropTypes.string, bodyStyle: _react2['default'].PropTypes.object, style: _react2['default'].PropTypes.object, rowKey: _react2['default'].PropTypes.func, rowClassName: _react2['default'].PropTypes.func, expandedRowClassName: _react2['default'].PropTypes.func, childrenColumnName: _react2['default'].PropTypes.string }, getDefaultProps: function getDefaultProps() { return { data: [], useFixedHeader: false, expandIconAsCell: false, columns: [], rowKey: function rowKey(o) { return o.key; }, rowClassName: function rowClassName() { return ''; }, expandedRowClassName: function expandedRowClassName() { return ''; }, prefixCls: 'rc-table', bodyStyle: {}, style: {}, childrenColumnName: 'children' }; }, getInitialState: function getInitialState() { return { expandedRows: [], data: this.props.data.concat() }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('data' in nextProps) { this.setState({ data: nextProps.data.concat() }); } }, onExpanded: function onExpanded(expanded, record) { var expandedRows = this.state.expandedRows.concat(); var info = expandedRows.filter(function (i) { return i.record === record; }); if (info.length) { info[0].expanded = expanded; } else { expandedRows.push({ record: record, expanded: expanded }); } this.setState({ expandedRows: expandedRows }); }, onRowDestroy: function onRowDestroy(record) { var expandedRows = this.state.expandedRows; var index = -1; expandedRows.forEach(function (r, i) { if (r === record) { index = i; } }); if (index !== -1) { expandedRows.splice(index, 1); } }, getThs: function getThs() { var ths = []; if (this.props.expandIconAsCell) { ths.push({ key: 'rc-table-expandIconAsCell', className: this.props.prefixCls + '-expand-icon-th', title: '' }); } ths = ths.concat(this.props.columns); return ths.map(function (c) { return _react2['default'].createElement( 'th', { key: c.key, className: c.className || '' }, c.title ); }); }, getExpandedRow: function getExpandedRow(key2, content, visible, className) { var key = key2; var prefixCls = this.props.prefixCls; if (key) { key += '-extra-row'; } return _react2['default'].createElement( 'tr', { key: key, style: { display: visible ? '' : 'none' }, className: prefixCls + '-expanded-row ' + className }, this.props.expandIconAsCell ? _react2['default'].createElement('td', { key: 'rc-table-expand-icon-placeholder' }) : '', _react2['default'].createElement( 'td', { colSpan: this.props.columns.length }, content ) ); }, getRowsByData: function getRowsByData(data, visible) { var props = this.props; var columns = props.columns; var childrenColumnName = props.childrenColumnName; var expandedRowRender = props.expandedRowRender; var expandIconAsCell = props.expandIconAsCell; var rst = []; var keyFn = props.rowKey; var rowClassName = props.rowClassName; var expandedRowClassName = props.expandedRowClassName; for (var i = 0; i < data.length; i++) { var record = data[i]; var key = keyFn ? keyFn(record, i) : undefined; var childrenColumn = record[childrenColumnName]; var expandedRowContent = undefined; if (expandedRowRender) { expandedRowContent = expandedRowRender(record, i); } var className = rowClassName(record, i); rst.push(_react2['default'].createElement(_TableRow2['default'], { className: className, record: record, expandIconAsCell: expandIconAsCell, onDestroy: this.onRowDestroy, index: i, visible: visible, onExpand: this.onExpanded, expandable: childrenColumn || expandedRowContent, expanded: this.isRowExpanded(record), prefixCls: props.prefixCls + '-row', childrenColumnName: childrenColumnName, columns: columns, key: key })); var subVisible = visible && this.isRowExpanded(record); if (expandedRowContent) { rst.push(this.getExpandedRow(key, expandedRowContent, subVisible, expandedRowClassName(record, i))); } if (childrenColumn) { rst = rst.concat(this.getRowsByData(childrenColumn, subVisible)); } } return rst; }, getRows: function getRows() { return this.getRowsByData(this.state.data, true); }, getColGroup: function getColGroup() { var cols = []; if (this.props.expandIconAsCell) { cols.push(_react2['default'].createElement('col', { className: this.props.prefixCls + '-expand-icon-col', key: 'rc-table-expand-icon-col' })); } cols = cols.concat(this.props.columns.map(function (c) { return _react2['default'].createElement('col', { key: c.key, style: { width: c.width } }); })); return _react2['default'].createElement( 'colgroup', null, cols ); }, render: function render() { var props = this.props; var prefixCls = props.prefixCls; var columns = this.getThs(); var rows = this.getRows(); var className = props.prefixCls; if (props.className) { className += ' ' + props.className; } var headerTable = undefined; var thead = _react2['default'].createElement( 'thead', { className: prefixCls + '-thead' }, _react2['default'].createElement( 'tr', null, columns ) ); if (props.useFixedHeader) { headerTable = _react2['default'].createElement( 'div', { className: prefixCls + '-header' }, _react2['default'].createElement( 'table', null, this.getColGroup(), thead ) ); thead = null; } return _react2['default'].createElement( 'div', { className: className, style: props.style }, headerTable, _react2['default'].createElement( 'div', { className: prefixCls + '-body', style: props.bodyStyle }, _react2['default'].createElement( 'table', null, this.getColGroup(), thead, _react2['default'].createElement( 'tbody', { className: prefixCls + '-tbody' }, rows ) ) ) ); }, isRowExpanded: function isRowExpanded(record) { var info = this.state.expandedRows.filter(function (i) { return i.record === record; }); return info[0] && info[0].expanded; } }); exports['default'] = Table; module.exports = exports['default']; /***/ }, /* 275 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var TableRow = _react2['default'].createClass({ displayName: 'TableRow', propTypes: { onDestroy: _react2['default'].PropTypes.func, record: _react2['default'].PropTypes.object, prefixCls: _react2['default'].PropTypes.string }, componentWillUnmount: function componentWillUnmount() { this.props.onDestroy(this.props.record); }, render: function render() { var props = this.props; var prefixCls = props.prefixCls; var columns = props.columns; var record = props.record; var index = props.index; var cells = []; var expanded = props.expanded; var expandable = props.expandable; var expandIconAsCell = props.expandIconAsCell; for (var i = 0; i < columns.length; i++) { var col = columns[i]; var colClassName = col.className || ''; var render = col.render; var text = record[col.dataIndex]; var expandIcon = null; if (i === 0 && expandable) { expandIcon = _react2['default'].createElement('span', { className: prefixCls + '-expand-icon ' + prefixCls + '-' + (expanded ? 'expanded' : 'collapsed'), onClick: props.onExpand.bind(null, !expanded, record) }); } if (expandIconAsCell && i === 0) { cells.push(_react2['default'].createElement( 'td', { className: prefixCls + '-expand-icon-cell', key: 'rc-table-expand-icon-cell' }, expandIcon )); expandIcon = null; } if (render) { text = render(text, record, index); } cells.push(_react2['default'].createElement( 'td', { key: col.key, className: '' + colClassName }, expandIcon, text )); } return _react2['default'].createElement( 'tr', { className: prefixCls + ' ' + props.className, style: { display: props.visible ? '' : 'none' } }, cells ); } }); exports['default'] = TableRow; module.exports = exports['default']; /***/ }, /* 276 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcMenu = __webpack_require__(223); var _rcMenu2 = _interopRequireDefault(_rcMenu); var _dropdown = __webpack_require__(209); var _dropdown2 = _interopRequireDefault(_dropdown); var FilterMenu = _react2['default'].createClass({ displayName: 'FilterMenu', getInitialState: function getInitialState() { return { selectedKeys: this.props.selectedKeys }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { this.setState({ selectedKeys: nextProps.selectedKeys }); }, getDefaultProps: function getDefaultProps() { return { handleFilter: function handleFilter() {}, column: null }; }, setSelectedKeys: function setSelectedKeys(_ref) { var selectedKeys = _ref.selectedKeys; this.setState({ selectedKeys: selectedKeys }); }, handleClearFilters: function handleClearFilters() { this.setState({ selectedKeys: [] }, this.handleConfirm); }, handleConfirm: function handleConfirm() { this.setState({ visible: false }); this.props.confirmFilter(this.props.column, this.state.selectedKeys); }, onVisibleChange: function onVisibleChange(visible) { this.setState({ visible: visible }); }, renderMenus: function renderMenus(items) { var menuItems = items.map(function (item) { return _react2['default'].createElement( _rcMenu2['default'].Item, { key: item.value }, item.text ); }); return menuItems; }, render: function render() { var column = this.props.column; var menus = _react2['default'].createElement( _rcMenu2['default'], { multiple: true, prefixCls: 'ant-dropdown-menu', className: 'ant-table-filter-dropdown', onSelect: this.setSelectedKeys, onDeselect: this.setSelectedKeys, selectedKeys: this.state.selectedKeys }, this.renderMenus(column.filters), _react2['default'].createElement(_rcMenu2['default'].Divider, null), _react2['default'].createElement( _rcMenu2['default'].Item, { disabled: true }, _react2['default'].createElement( 'a', { className: 'ant-table-filter-dropdown-link confirm', style: { cursor: 'pointer', pointerEvents: 'visible' }, onClick: this.handleConfirm }, '确定' ), _react2['default'].createElement( 'a', { className: 'ant-table-filter-dropdown-link clear', style: { cursor: 'pointer', pointerEvents: 'visible' }, onClick: this.handleClearFilters }, '清空' ) ) ); var dropdownSelectedClass = ''; if (this.props.selectedKeys.length > 0) { dropdownSelectedClass = 'ant-table-filter-selected'; } return _react2['default'].createElement( _dropdown2['default'], { trigger: 'click', overlay: menus, visible: this.state.visible, onVisibleChange: this.onVisibleChange }, _react2['default'].createElement('i', { title: '筛选', className: 'anticon anticon-bars ' + dropdownSelectedClass }) ); } }); exports['default'] = FilterMenu; module.exports = exports['default']; /***/ }, /* 277 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var prefixCls = 'ant-tag'; var AntTag = (function (_React$Component) { _inherits(AntTag, _React$Component); function AntTag(props) { _classCallCheck(this, AntTag); _get(Object.getPrototypeOf(AntTag.prototype), 'constructor', this).call(this, props); this.state = { closing: false, closed: false }; } _createClass(AntTag, [{ key: 'close', value: function close(e) { var dom = _react2['default'].findDOMNode(this); dom.style.width = dom.offsetWidth + 'px'; // It's Magic Code, don't know why dom.style.width = dom.offsetWidth + 'px'; this.setState({ closing: true }); this.props.onClose.call(this, e); } }, { key: 'animationEnd', value: function animationEnd() { this.setState({ closed: true, closing: false }); } }, { key: 'render', value: function render() { var close = this.props.closable ? _react2['default'].createElement('i', { className: 'anticon anticon-cross', onClick: this.close.bind(this) }) : ''; var colorClass = this.props.color ? this.props.prefixCls + '-' + this.props.color : ''; var className = this.props.prefixCls + ' ' + colorClass; className = this.state.closing ? className + ' ' + this.props.prefixCls + '-close' : className; return this.state.closed ? null : _react2['default'].createElement( _rcAnimate2['default'], { component: '', showProp: 'data-show', transitionName: 'zoom-tag', onEnd: this.animationEnd.bind(this) }, _react2['default'].createElement( 'div', { 'data-show': !this.state.closing, className: className }, _react2['default'].createElement('a', _extends({ className: this.props.prefixCls + '-text' }, this.props)), close ) ); } }]); return AntTag; })(_react2['default'].Component); AntTag.defaultProps = { prefixCls: prefixCls, closable: false, onClose: function onClose() {} }; exports['default'] = AntTag; module.exports = exports['default']; /***/ }, /* 278 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _rcCollapse = __webpack_require__(279); var _rcCollapse2 = _interopRequireDefault(_rcCollapse); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var prefixCls = 'ant-collapse'; var AntCollapse = (function (_React$Component) { _inherits(AntCollapse, _React$Component); function AntCollapse() { _classCallCheck(this, AntCollapse); _get(Object.getPrototypeOf(AntCollapse.prototype), 'constructor', this).apply(this, arguments); } _createClass(AntCollapse, [{ key: 'render', value: function render() { return _react2['default'].createElement(_rcCollapse2['default'], this.props); } }]); return AntCollapse; })(_react2['default'].Component); AntCollapse.defaultProps = { prefixCls: prefixCls }; AntCollapse.Panel = _rcCollapse2['default'].Panel; exports['default'] = AntCollapse; module.exports = exports['default']; /***/ }, /* 279 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Collapse = __webpack_require__(280); var _Collapse2 = _interopRequireDefault(_Collapse); exports['default'] = _Collapse2['default']; module.exports = exports['default']; /***/ }, /* 280 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _Panel = __webpack_require__(281); var _Panel2 = _interopRequireDefault(_Panel); var _openAnimation = __webpack_require__(283); var _openAnimation2 = _interopRequireDefault(_openAnimation); var Collapse = (0, _react.createClass)({ statics: { Panel: _Panel2['default'] }, propTypes: { prefixCls: _react.PropTypes.string, activeKey: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.arrayOf(_react.PropTypes.string)]), defaultActiveKey: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.arrayOf(_react.PropTypes.string)]), openAnimation: _react.PropTypes.object, onChange: _react.PropTypes.func, accordion: _react.PropTypes.bool }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-collapse', onChange: function onChange() {}, openAnimation: _openAnimation2['default'], accordion: false }; }, getInitialState: function getInitialState() { var _props = this.props; var activeKey = _props.activeKey; var accordion = _props.accordion; var defaultActiveKey = this.props.defaultActiveKey; // If is not accordion mode, then, defaultActiveKey should be an array if (!accordion) { defaultActiveKey = defaultActiveKey || []; } return { activeKey: activeKey || defaultActiveKey }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('activeKey' in nextProps) { this.setState({ activeKey: nextProps.activeKey }); } }, handleClickItem: function handleClickItem(key) { var _this = this; return function () { var activeKey = _this._getActivityKey(); if (_this.props.accordion) { _this.setState({ activeKey: key === activeKey ? null : key }); } else { var index = activeKey.indexOf(key); var isActive = index > -1; if (isActive) { // remove active state activeKey.splice(index, 1); } else { activeKey.push(key); } _this.setState({ activeKey: activeKey }); } _this.props.onChange(key); }; }, _getActivityKey: function _getActivityKey() { var activeKey = this.state.activeKey; var accordion = this.props.accordion; if (accordion && Array.isArray(activeKey)) { activeKey = activeKey[0]; } if (!accordion && !Array.isArray(activeKey)) { activeKey = activeKey ? [activeKey] : []; } return activeKey; }, getItems: function getItems() { var _this2 = this; var activeKey = this._getActivityKey(); var _props2 = this.props; var prefixCls = _props2.prefixCls; var accordion = _props2.accordion; return _react.Children.map(this.props.children, function (child, i) { // If there is no key provide, use the panel order as default key var key = child.key || i; var header = child.props.header; var isActive = false; if (accordion) { isActive = activeKey === key; } else { isActive = activeKey.indexOf(key) > -1; } var props = { key: key, header: header, isActive: isActive, prefixCls: prefixCls, openAnimation: _this2.props.openAnimation, children: child.props.children, onItemClick: _this2.handleClickItem(key).bind(_this2) }; return _react2['default'].createElement(_Panel2['default'], props); }); }, render: function render() { var prefixCls = this.props.prefixCls; return _react2['default'].createElement( 'div', { className: prefixCls }, this.getItems() ); } }); exports['default'] = Collapse; module.exports = exports['default']; /***/ }, /* 281 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _classnames2 = __webpack_require__(282); var _classnames3 = _interopRequireDefault(_classnames2); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var CollapsePanel = (0, _react.createClass)({ propTypes: { openAnimation: _react.PropTypes.object, prefixCls: _react.PropTypes.string, header: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number, _react.PropTypes.node]), isActive: _react.PropTypes.bool, onItemClick: _react.PropTypes.func }, getInitialState: function getInitialState() { return { isActive: this.props.isActive }; }, getDefaultProps: function getDefaultProps() { return { isActive: false, onItemClick: function onItemClick() {} }; }, handleItemClick: function handleItemClick() { this.props.onItemClick(); }, render: function render() { var _classnames; var _props = this.props; var prefixCls = _props.prefixCls; var header = _props.header; var children = _props.children; var isActive = _props.isActive; var headerCls = prefixCls + '-header'; var contentCls = (0, _classnames3['default'])((_classnames = {}, _defineProperty(_classnames, prefixCls + '-content', true), _defineProperty(_classnames, prefixCls + '-content-active', isActive), _classnames)); return _react2['default'].createElement( 'div', { className: prefixCls + '-item' }, _react2['default'].createElement( 'div', { className: headerCls, onClick: this.handleItemClick, role: 'tab', 'aria-expanded': isActive }, _react2['default'].createElement('i', { className: 'arrow' }), header ), _react2['default'].createElement( _rcAnimate2['default'], { showProp: 'data-active', exclusive: true, animation: this.props.openAnimation }, _react2['default'].createElement( 'div', { className: contentCls, 'data-active': isActive, role: 'tabpanel' }, _react2['default'].createElement( 'div', { className: prefixCls + '-content-box' }, children ) ) ) ); } }); exports['default'] = CollapsePanel; module.exports = exports['default']; /***/ }, /* 282 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/*! Copyright (c) 2015 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ /* global define */ (function () { 'use strict'; var hasOwn = {}.hasOwnProperty; function classNames () { var classes = ''; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (!arg) continue; var argType = typeof arg; if (argType === 'string' || argType === 'number') { classes += ' ' + arg; } else if (Array.isArray(arg)) { classes += ' ' + classNames.apply(null, arg); } else if (argType === 'object') { for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes += ' ' + key; } } } } return classes.substr(1); } if (typeof module !== 'undefined' && module.exports) { module.exports = classNames; } else if (true) { // register as 'classnames', consistent with npm package name !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { return classNames; }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else { window.classNames = classNames; } }()); /***/ }, /* 283 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _velocityAnimate = __webpack_require__(284); var _velocityAnimate2 = _interopRequireDefault(_velocityAnimate); function animate(node, show, transitionName, done) { var ok = undefined; function complete() { if (!ok) { ok = true; done(); } } // Fix safari flash bug node.style.display = show ? 'block' : 'none'; (0, _velocityAnimate2['default'])(node, transitionName, { duration: 240, complete: complete, easing: 'easeInOutQuad' }); return { stop: function stop() { (0, _velocityAnimate2['default'])(node, 'finish'); complete(); } }; } var animation = { enter: function enter(node, done) { return animate(node, false, 'slideDown', done); }, leave: function leave(node, done) { return animate(node, true, 'slideUp', done); } }; exports['default'] = animation; module.exports = exports['default']; /***/ }, /* 284 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! VelocityJS.org (1.2.3). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */ /************************* Velocity jQuery Shim *************************/ /*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */ /* This file contains the jQuery functions that Velocity relies on, thereby removing Velocity's dependency on a full copy of jQuery, and allowing it to work in any environment. */ /* These shimmed functions are only used if jQuery isn't present. If both this shim and jQuery are loaded, Velocity defaults to jQuery proper. */ /* Browser support: Using this shim instead of jQuery proper removes support for IE8. */ ;(function (window) { /*************** Setup ***************/ /* If jQuery is already loaded, there's no point in loading this shim. */ if (window.jQuery) { return; } /* jQuery base. */ var $ = function (selector, context) { return new $.fn.init(selector, context); }; /******************** Private Methods ********************/ /* jQuery */ $.isWindow = function (obj) { /* jshint eqeqeq: false */ return obj != null && obj == obj.window; }; /* jQuery */ $.type = function (obj) { if (obj == null) { return obj + ""; } return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj; }; /* jQuery */ $.isArray = Array.isArray || function (obj) { return $.type(obj) === "array"; }; /* jQuery */ function isArraylike (obj) { var length = obj.length, type = $.type(obj); if (type === "function" || $.isWindow(obj)) { return false; } if (obj.nodeType === 1 && length) { return true; } return type === "array" || length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj; } /*************** $ Methods ***************/ /* jQuery: Support removed for IE<9. */ $.isPlainObject = function (obj) { var key; if (!obj || $.type(obj) !== "object" || obj.nodeType || $.isWindow(obj)) { return false; } try { if (obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { return false; } } catch (e) { return false; } for (key in obj) {} return key === undefined || hasOwn.call(obj, key); }; /* jQuery */ $.each = function(obj, callback, args) { var value, i = 0, length = obj.length, isArray = isArraylike(obj); if (args) { if (isArray) { for (; i < length; i++) { value = callback.apply(obj[i], args); if (value === false) { break; } } } else { for (i in obj) { value = callback.apply(obj[i], args); if (value === false) { break; } } } } else { if (isArray) { for (; i < length; i++) { value = callback.call(obj[i], i, obj[i]); if (value === false) { break; } } } else { for (i in obj) { value = callback.call(obj[i], i, obj[i]); if (value === false) { break; } } } } return obj; }; /* Custom */ $.data = function (node, key, value) { /* $.getData() */ if (value === undefined) { var id = node[$.expando], store = id && cache[id]; if (key === undefined) { return store; } else if (store) { if (key in store) { return store[key]; } } /* $.setData() */ } else if (key !== undefined) { var id = node[$.expando] || (node[$.expando] = ++$.uuid); cache[id] = cache[id] || {}; cache[id][key] = value; return value; } }; /* Custom */ $.removeData = function (node, keys) { var id = node[$.expando], store = id && cache[id]; if (store) { $.each(keys, function(_, key) { delete store[key]; }); } }; /* jQuery */ $.extend = function () { var src, copyIsArray, copy, name, options, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; if (typeof target === "boolean") { deep = target; target = arguments[i] || {}; i++; } if (typeof target !== "object" && $.type(target) !== "function") { target = {}; } if (i === length) { target = this; i--; } for (; i < length; i++) { if ((options = arguments[i]) != null) { for (name in options) { src = target[name]; copy = options[name]; if (target === copy) { continue; } if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) { if (copyIsArray) { copyIsArray = false; clone = src && $.isArray(src) ? src : []; } else { clone = src && $.isPlainObject(src) ? src : {}; } target[name] = $.extend(deep, clone, copy); } else if (copy !== undefined) { target[name] = copy; } } } } return target; }; /* jQuery 1.4.3 */ $.queue = function (elem, type, data) { function $makeArray (arr, results) { var ret = results || []; if (arr != null) { if (isArraylike(Object(arr))) { /* $.merge */ (function(first, second) { var len = +second.length, j = 0, i = first.length; while (j < len) { first[i++] = second[j++]; } if (len !== len) { while (second[j] !== undefined) { first[i++] = second[j++]; } } first.length = i; return first; })(ret, typeof arr === "string" ? [arr] : arr); } else { [].push.call(ret, arr); } } return ret; } if (!elem) { return; } type = (type || "fx") + "queue"; var q = $.data(elem, type); if (!data) { return q || []; } if (!q || $.isArray(data)) { q = $.data(elem, type, $makeArray(data)); } else { q.push(data); } return q; }; /* jQuery 1.4.3 */ $.dequeue = function (elems, type) { /* Custom: Embed element iteration. */ $.each(elems.nodeType ? [ elems ] : elems, function(i, elem) { type = type || "fx"; var queue = $.queue(elem, type), fn = queue.shift(); if (fn === "inprogress") { fn = queue.shift(); } if (fn) { if (type === "fx") { queue.unshift("inprogress"); } fn.call(elem, function() { $.dequeue(elem, type); }); } }); }; /****************** $.fn Methods ******************/ /* jQuery */ $.fn = $.prototype = { init: function (selector) { /* Just return the element wrapped inside an array; don't proceed with the actual jQuery node wrapping process. */ if (selector.nodeType) { this[0] = selector; return this; } else { throw new Error("Not a DOM node."); } }, offset: function () { /* jQuery altered code: Dropped disconnected DOM node checking. */ var box = this[0].getBoundingClientRect ? this[0].getBoundingClientRect() : { top: 0, left: 0 }; return { top: box.top + (window.pageYOffset || document.scrollTop || 0) - (document.clientTop || 0), left: box.left + (window.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || 0) }; }, position: function () { /* jQuery */ function offsetParent() { var offsetParent = this.offsetParent || document; while (offsetParent && (!offsetParent.nodeType.toLowerCase === "html" && offsetParent.style.position === "static")) { offsetParent = offsetParent.offsetParent; } return offsetParent || document; } /* Zepto */ var elem = this[0], offsetParent = offsetParent.apply(elem), offset = this.offset(), parentOffset = /^(?:body|html)$/i.test(offsetParent.nodeName) ? { top: 0, left: 0 } : $(offsetParent).offset() offset.top -= parseFloat(elem.style.marginTop) || 0; offset.left -= parseFloat(elem.style.marginLeft) || 0; if (offsetParent.style) { parentOffset.top += parseFloat(offsetParent.style.borderTopWidth) || 0 parentOffset.left += parseFloat(offsetParent.style.borderLeftWidth) || 0 } return { top: offset.top - parentOffset.top, left: offset.left - parentOffset.left }; } }; /********************** Private Variables **********************/ /* For $.data() */ var cache = {}; $.expando = "velocity" + (new Date().getTime()); $.uuid = 0; /* For $.queue() */ var class2type = {}, hasOwn = class2type.hasOwnProperty, toString = class2type.toString; var types = "Boolean Number String Function Array Date RegExp Object Error".split(" "); for (var i = 0; i < types.length; i++) { class2type["[object " + types[i] + "]"] = types[i].toLowerCase(); } /* Makes $(node) possible, without having to call init. */ $.fn.init.prototype = $.fn; /* Globalize Velocity onto the window, and assign its Utilities property. */ window.Velocity = { Utilities: $ }; })(window); /****************** Velocity.js ******************/ ;(function (factory) { /* CommonJS module. */ if (typeof module === "object" && typeof module.exports === "object") { module.exports = factory(); /* AMD module. */ } else if (true) { !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); /* Browser globals. */ } else { factory(); } }(function() { return function (global, window, document, undefined) { /*************** Summary ***************/ /* - CSS: CSS stack that works independently from the rest of Velocity. - animate(): Core animation method that iterates over the targeted elements and queues the incoming call onto each element individually. - Pre-Queueing: Prepare the element for animation by instantiating its data cache and processing the call's options. - Queueing: The logic that runs once the call has reached its point of execution in the element's $.queue() stack. Most logic is placed here to avoid risking it becoming stale (if the element's properties have changed). - Pushing: Consolidation of the tween data followed by its push onto the global in-progress calls container. - tick(): The single requestAnimationFrame loop responsible for tweening all in-progress calls. - completeCall(): Handles the cleanup process for each Velocity call. */ /********************* Helper Functions *********************/ /* IE detection. Gist: https://gist.github.com/julianshapiro/9098609 */ var IE = (function() { if (document.documentMode) { return document.documentMode; } else { for (var i = 7; i > 4; i--) { var div = document.createElement("div"); div.innerHTML = "<!--[if IE " + i + "]><span></span><![endif]-->"; if (div.getElementsByTagName("span").length) { div = null; return i; } } } return undefined; })(); /* rAF shim. Gist: https://gist.github.com/julianshapiro/9497513 */ var rAFShim = (function() { var timeLast = 0; return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { var timeCurrent = (new Date()).getTime(), timeDelta; /* Dynamically set delay on a per-tick basis to match 60fps. */ /* Technique by Erik Moller. MIT license: https://gist.github.com/paulirish/1579671 */ timeDelta = Math.max(0, 16 - (timeCurrent - timeLast)); timeLast = timeCurrent + timeDelta; return setTimeout(function() { callback(timeCurrent + timeDelta); }, timeDelta); }; })(); /* Array compacting. Copyright Lo-Dash. MIT License: https://github.com/lodash/lodash/blob/master/LICENSE.txt */ function compactSparseArray (array) { var index = -1, length = array ? array.length : 0, result = []; while (++index < length) { var value = array[index]; if (value) { result.push(value); } } return result; } function sanitizeElements (elements) { /* Unwrap jQuery/Zepto objects. */ if (Type.isWrapped(elements)) { elements = [].slice.call(elements); /* Wrap a single element in an array so that $.each() can iterate with the element instead of its node's children. */ } else if (Type.isNode(elements)) { elements = [ elements ]; } return elements; } var Type = { isString: function (variable) { return (typeof variable === "string"); }, isArray: Array.isArray || function (variable) { return Object.prototype.toString.call(variable) === "[object Array]"; }, isFunction: function (variable) { return Object.prototype.toString.call(variable) === "[object Function]"; }, isNode: function (variable) { return variable && variable.nodeType; }, /* Copyright Martin Bohm. MIT License: https://gist.github.com/Tomalak/818a78a226a0738eaade */ isNodeList: function (variable) { return typeof variable === "object" && /^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(variable)) && variable.length !== undefined && (variable.length === 0 || (typeof variable[0] === "object" && variable[0].nodeType > 0)); }, /* Determine if variable is a wrapped jQuery or Zepto element. */ isWrapped: function (variable) { return variable && (variable.jquery || (window.Zepto && window.Zepto.zepto.isZ(variable))); }, isSVG: function (variable) { return window.SVGElement && (variable instanceof window.SVGElement); }, isEmptyObject: function (variable) { for (var name in variable) { return false; } return true; } }; /***************** Dependencies *****************/ var $, isJQuery = false; if (global.fn && global.fn.jquery) { $ = global; isJQuery = true; } else { $ = window.Velocity.Utilities; } if (IE <= 8 && !isJQuery) { throw new Error("Velocity: IE8 and below require jQuery to be loaded before Velocity."); } else if (IE <= 7) { /* Revert to jQuery's $.animate(), and lose Velocity's extra features. */ jQuery.fn.velocity = jQuery.fn.animate; /* Now that $.fn.velocity is aliased, abort this Velocity declaration. */ return; } /***************** Constants *****************/ var DURATION_DEFAULT = 400, EASING_DEFAULT = "swing"; /************* State *************/ var Velocity = { /* Container for page-wide Velocity state data. */ State: { /* Detect mobile devices to determine if mobileHA should be turned on. */ isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), /* The mobileHA option's behavior changes on older Android devices (Gingerbread, versions 2.3.3-2.3.7). */ isAndroid: /Android/i.test(navigator.userAgent), isGingerbread: /Android 2\.3\.[3-7]/i.test(navigator.userAgent), isChrome: window.chrome, isFirefox: /Firefox/i.test(navigator.userAgent), /* Create a cached element for re-use when checking for CSS property prefixes. */ prefixElement: document.createElement("div"), /* Cache every prefix match to avoid repeating lookups. */ prefixMatches: {}, /* Cache the anchor used for animating window scrolling. */ scrollAnchor: null, /* Cache the browser-specific property names associated with the scroll anchor. */ scrollPropertyLeft: null, scrollPropertyTop: null, /* Keep track of whether our RAF tick is running. */ isTicking: false, /* Container for every in-progress call to Velocity. */ calls: [] }, /* Velocity's custom CSS stack. Made global for unit testing. */ CSS: { /* Defined below. */ }, /* A shim of the jQuery utility functions used by Velocity -- provided by Velocity's optional jQuery shim. */ Utilities: $, /* Container for the user's custom animation redirects that are referenced by name in place of the properties map argument. */ Redirects: { /* Manually registered by the user. */ }, Easings: { /* Defined below. */ }, /* Attempt to use ES6 Promises by default. Users can override this with a third-party promises library. */ Promise: window.Promise, /* Velocity option defaults, which can be overriden by the user. */ defaults: { queue: "", duration: DURATION_DEFAULT, easing: EASING_DEFAULT, begin: undefined, complete: undefined, progress: undefined, display: undefined, visibility: undefined, loop: false, delay: false, mobileHA: true, /* Advanced: Set to false to prevent property values from being cached between consecutive Velocity-initiated chain calls. */ _cacheValues: true }, /* A design goal of Velocity is to cache data wherever possible in order to avoid DOM requerying. Accordingly, each element has a data cache. */ init: function (element) { $.data(element, "velocity", { /* Store whether this is an SVG element, since its properties are retrieved and updated differently than standard HTML elements. */ isSVG: Type.isSVG(element), /* Keep track of whether the element is currently being animated by Velocity. This is used to ensure that property values are not transferred between non-consecutive (stale) calls. */ isAnimating: false, /* A reference to the element's live computedStyle object. Learn more here: https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle */ computedStyle: null, /* Tween data is cached for each animation on the element so that data can be passed across calls -- in particular, end values are used as subsequent start values in consecutive Velocity calls. */ tweensContainer: null, /* The full root property values of each CSS hook being animated on this element are cached so that: 1) Concurrently-animating hooks sharing the same root can have their root values' merged into one while tweening. 2) Post-hook-injection root values can be transferred over to consecutively chained Velocity calls as starting root values. */ rootPropertyValueCache: {}, /* A cache for transform updates, which must be manually flushed via CSS.flushTransformCache(). */ transformCache: {} }); }, /* A parallel to jQuery's $.css(), used for getting/setting Velocity's hooked CSS properties. */ hook: null, /* Defined below. */ /* Velocity-wide animation time remapping for testing purposes. */ mock: false, version: { major: 1, minor: 2, patch: 2 }, /* Set to 1 or 2 (most verbose) to output debug info to console. */ debug: false }; /* Retrieve the appropriate scroll anchor and property name for the browser: https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY */ if (window.pageYOffset !== undefined) { Velocity.State.scrollAnchor = window; Velocity.State.scrollPropertyLeft = "pageXOffset"; Velocity.State.scrollPropertyTop = "pageYOffset"; } else { Velocity.State.scrollAnchor = document.documentElement || document.body.parentNode || document.body; Velocity.State.scrollPropertyLeft = "scrollLeft"; Velocity.State.scrollPropertyTop = "scrollTop"; } /* Shorthand alias for jQuery's $.data() utility. */ function Data (element) { /* Hardcode a reference to the plugin name. */ var response = $.data(element, "velocity"); /* jQuery <=1.4.2 returns null instead of undefined when no match is found. We normalize this behavior. */ return response === null ? undefined : response; }; /************** Easing **************/ /* Step easing generator. */ function generateStep (steps) { return function (p) { return Math.round(p * steps) * (1 / steps); }; } /* Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */ function generateBezier (mX1, mY1, mX2, mY2) { var NEWTON_ITERATIONS = 4, NEWTON_MIN_SLOPE = 0.001, SUBDIVISION_PRECISION = 0.0000001, SUBDIVISION_MAX_ITERATIONS = 10, kSplineTableSize = 11, kSampleStepSize = 1.0 / (kSplineTableSize - 1.0), float32ArraySupported = "Float32Array" in window; /* Must contain four arguments. */ if (arguments.length !== 4) { return false; } /* Arguments must be numbers. */ for (var i = 0; i < 4; ++i) { if (typeof arguments[i] !== "number" || isNaN(arguments[i]) || !isFinite(arguments[i])) { return false; } } /* X values must be in the [0, 1] range. */ mX1 = Math.min(mX1, 1); mX2 = Math.min(mX2, 1); mX1 = Math.max(mX1, 0); mX2 = Math.max(mX2, 0); var mSampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize); function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; } function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; } function C (aA1) { return 3.0 * aA1; } function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2)*aT + B(aA1, aA2))*aT + C(aA1))*aT; } function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2)*aT*aT + 2.0 * B(aA1, aA2) * aT + C(aA1); } function newtonRaphsonIterate (aX, aGuessT) { for (var i = 0; i < NEWTON_ITERATIONS; ++i) { var currentSlope = getSlope(aGuessT, mX1, mX2); if (currentSlope === 0.0) return aGuessT; var currentX = calcBezier(aGuessT, mX1, mX2) - aX; aGuessT -= currentX / currentSlope; } return aGuessT; } function calcSampleValues () { for (var i = 0; i < kSplineTableSize; ++i) { mSampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2); } } function binarySubdivide (aX, aA, aB) { var currentX, currentT, i = 0; do { currentT = aA + (aB - aA) / 2.0; currentX = calcBezier(currentT, mX1, mX2) - aX; if (currentX > 0.0) { aB = currentT; } else { aA = currentT; } } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS); return currentT; } function getTForX (aX) { var intervalStart = 0.0, currentSample = 1, lastSample = kSplineTableSize - 1; for (; currentSample != lastSample && mSampleValues[currentSample] <= aX; ++currentSample) { intervalStart += kSampleStepSize; } --currentSample; var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample+1] - mSampleValues[currentSample]), guessForT = intervalStart + dist * kSampleStepSize, initialSlope = getSlope(guessForT, mX1, mX2); if (initialSlope >= NEWTON_MIN_SLOPE) { return newtonRaphsonIterate(aX, guessForT); } else if (initialSlope == 0.0) { return guessForT; } else { return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize); } } var _precomputed = false; function precompute() { _precomputed = true; if (mX1 != mY1 || mX2 != mY2) calcSampleValues(); } var f = function (aX) { if (!_precomputed) precompute(); if (mX1 === mY1 && mX2 === mY2) return aX; if (aX === 0) return 0; if (aX === 1) return 1; return calcBezier(getTForX(aX), mY1, mY2); }; f.getControlPoints = function() { return [{ x: mX1, y: mY1 }, { x: mX2, y: mY2 }]; }; var str = "generateBezier(" + [mX1, mY1, mX2, mY2] + ")"; f.toString = function () { return str; }; return f; } /* Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */ /* Given a tension, friction, and duration, a simulation at 60FPS will first run without a defined duration in order to calculate the full path. A second pass then adjusts the time delta -- using the relation between actual time and duration -- to calculate the path for the duration-constrained animation. */ var generateSpringRK4 = (function () { function springAccelerationForState (state) { return (-state.tension * state.x) - (state.friction * state.v); } function springEvaluateStateWithDerivative (initialState, dt, derivative) { var state = { x: initialState.x + derivative.dx * dt, v: initialState.v + derivative.dv * dt, tension: initialState.tension, friction: initialState.friction }; return { dx: state.v, dv: springAccelerationForState(state) }; } function springIntegrateState (state, dt) { var a = { dx: state.v, dv: springAccelerationForState(state) }, b = springEvaluateStateWithDerivative(state, dt * 0.5, a), c = springEvaluateStateWithDerivative(state, dt * 0.5, b), d = springEvaluateStateWithDerivative(state, dt, c), dxdt = 1.0 / 6.0 * (a.dx + 2.0 * (b.dx + c.dx) + d.dx), dvdt = 1.0 / 6.0 * (a.dv + 2.0 * (b.dv + c.dv) + d.dv); state.x = state.x + dxdt * dt; state.v = state.v + dvdt * dt; return state; } return function springRK4Factory (tension, friction, duration) { var initState = { x: -1, v: 0, tension: null, friction: null }, path = [0], time_lapsed = 0, tolerance = 1 / 10000, DT = 16 / 1000, have_duration, dt, last_state; tension = parseFloat(tension) || 500; friction = parseFloat(friction) || 20; duration = duration || null; initState.tension = tension; initState.friction = friction; have_duration = duration !== null; /* Calculate the actual time it takes for this animation to complete with the provided conditions. */ if (have_duration) { /* Run the simulation without a duration. */ time_lapsed = springRK4Factory(tension, friction); /* Compute the adjusted time delta. */ dt = time_lapsed / duration * DT; } else { dt = DT; } while (true) { /* Next/step function .*/ last_state = springIntegrateState(last_state || initState, dt); /* Store the position. */ path.push(1 + last_state.x); time_lapsed += 16; /* If the change threshold is reached, break. */ if (!(Math.abs(last_state.x) > tolerance && Math.abs(last_state.v) > tolerance)) { break; } } /* If duration is not defined, return the actual time required for completing this animation. Otherwise, return a closure that holds the computed path and returns a snapshot of the position according to a given percentComplete. */ return !have_duration ? time_lapsed : function(percentComplete) { return path[ (percentComplete * (path.length - 1)) | 0 ]; }; }; }()); /* jQuery easings. */ Velocity.Easings = { linear: function(p) { return p; }, swing: function(p) { return 0.5 - Math.cos( p * Math.PI ) / 2 }, /* Bonus "spring" easing, which is a less exaggerated version of easeInOutElastic. */ spring: function(p) { return 1 - (Math.cos(p * 4.5 * Math.PI) * Math.exp(-p * 6)); } }; /* CSS3 and Robert Penner easings. */ $.each( [ [ "ease", [ 0.25, 0.1, 0.25, 1.0 ] ], [ "ease-in", [ 0.42, 0.0, 1.00, 1.0 ] ], [ "ease-out", [ 0.00, 0.0, 0.58, 1.0 ] ], [ "ease-in-out", [ 0.42, 0.0, 0.58, 1.0 ] ], [ "easeInSine", [ 0.47, 0, 0.745, 0.715 ] ], [ "easeOutSine", [ 0.39, 0.575, 0.565, 1 ] ], [ "easeInOutSine", [ 0.445, 0.05, 0.55, 0.95 ] ], [ "easeInQuad", [ 0.55, 0.085, 0.68, 0.53 ] ], [ "easeOutQuad", [ 0.25, 0.46, 0.45, 0.94 ] ], [ "easeInOutQuad", [ 0.455, 0.03, 0.515, 0.955 ] ], [ "easeInCubic", [ 0.55, 0.055, 0.675, 0.19 ] ], [ "easeOutCubic", [ 0.215, 0.61, 0.355, 1 ] ], [ "easeInOutCubic", [ 0.645, 0.045, 0.355, 1 ] ], [ "easeInQuart", [ 0.895, 0.03, 0.685, 0.22 ] ], [ "easeOutQuart", [ 0.165, 0.84, 0.44, 1 ] ], [ "easeInOutQuart", [ 0.77, 0, 0.175, 1 ] ], [ "easeInQuint", [ 0.755, 0.05, 0.855, 0.06 ] ], [ "easeOutQuint", [ 0.23, 1, 0.32, 1 ] ], [ "easeInOutQuint", [ 0.86, 0, 0.07, 1 ] ], [ "easeInExpo", [ 0.95, 0.05, 0.795, 0.035 ] ], [ "easeOutExpo", [ 0.19, 1, 0.22, 1 ] ], [ "easeInOutExpo", [ 1, 0, 0, 1 ] ], [ "easeInCirc", [ 0.6, 0.04, 0.98, 0.335 ] ], [ "easeOutCirc", [ 0.075, 0.82, 0.165, 1 ] ], [ "easeInOutCirc", [ 0.785, 0.135, 0.15, 0.86 ] ] ], function(i, easingArray) { Velocity.Easings[easingArray[0]] = generateBezier.apply(null, easingArray[1]); }); /* Determine the appropriate easing type given an easing input. */ function getEasing(value, duration) { var easing = value; /* The easing option can either be a string that references a pre-registered easing, or it can be a two-/four-item array of integers to be converted into a bezier/spring function. */ if (Type.isString(value)) { /* Ensure that the easing has been assigned to jQuery's Velocity.Easings object. */ if (!Velocity.Easings[value]) { easing = false; } } else if (Type.isArray(value) && value.length === 1) { easing = generateStep.apply(null, value); } else if (Type.isArray(value) && value.length === 2) { /* springRK4 must be passed the animation's duration. */ /* Note: If the springRK4 array contains non-numbers, generateSpringRK4() returns an easing function generated with default tension and friction values. */ easing = generateSpringRK4.apply(null, value.concat([ duration ])); } else if (Type.isArray(value) && value.length === 4) { /* Note: If the bezier array contains non-numbers, generateBezier() returns false. */ easing = generateBezier.apply(null, value); } else { easing = false; } /* Revert to the Velocity-wide default easing type, or fall back to "swing" (which is also jQuery's default) if the Velocity-wide default has been incorrectly modified. */ if (easing === false) { if (Velocity.Easings[Velocity.defaults.easing]) { easing = Velocity.defaults.easing; } else { easing = EASING_DEFAULT; } } return easing; } /***************** CSS Stack *****************/ /* The CSS object is a highly condensed and performant CSS stack that fully replaces jQuery's. It handles the validation, getting, and setting of both standard CSS properties and CSS property hooks. */ /* Note: A "CSS" shorthand is aliased so that our code is easier to read. */ var CSS = Velocity.CSS = { /************* RegEx *************/ RegEx: { isHex: /^#([A-f\d]{3}){1,2}$/i, /* Unwrap a property value's surrounding text, e.g. "rgba(4, 3, 2, 1)" ==> "4, 3, 2, 1" and "rect(4px 3px 2px 1px)" ==> "4px 3px 2px 1px". */ valueUnwrap: /^[A-z]+\((.*)\)$/i, wrappedValueAlreadyExtracted: /[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/, /* Split a multi-value property into an array of subvalues, e.g. "rgba(4, 3, 2, 1) 4px 3px 2px 1px" ==> [ "rgba(4, 3, 2, 1)", "4px", "3px", "2px", "1px" ]. */ valueSplit: /([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/ig }, /************ Lists ************/ Lists: { colors: [ "fill", "stroke", "stopColor", "color", "backgroundColor", "borderColor", "borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor", "outlineColor" ], transformsBase: [ "translateX", "translateY", "scale", "scaleX", "scaleY", "skewX", "skewY", "rotateZ" ], transforms3D: [ "transformPerspective", "translateZ", "scaleZ", "rotateX", "rotateY" ] }, /************ Hooks ************/ /* Hooks allow a subproperty (e.g. "boxShadowBlur") of a compound-value CSS property (e.g. "boxShadow: X Y Blur Spread Color") to be animated as if it were a discrete property. */ /* Note: Beyond enabling fine-grained property animation, hooking is necessary since Velocity only tweens properties with single numeric values; unlike CSS transitions, Velocity does not interpolate compound-values. */ Hooks: { /******************** Registration ********************/ /* Templates are a concise way of indicating which subproperties must be individually registered for each compound-value CSS property. */ /* Each template consists of the compound-value's base name, its constituent subproperty names, and those subproperties' default values. */ templates: { "textShadow": [ "Color X Y Blur", "black 0px 0px 0px" ], "boxShadow": [ "Color X Y Blur Spread", "black 0px 0px 0px 0px" ], "clip": [ "Top Right Bottom Left", "0px 0px 0px 0px" ], "backgroundPosition": [ "X Y", "0% 0%" ], "transformOrigin": [ "X Y Z", "50% 50% 0px" ], "perspectiveOrigin": [ "X Y", "50% 50%" ] }, /* A "registered" hook is one that has been converted from its template form into a live, tweenable property. It contains data to associate it with its root property. */ registered: { /* Note: A registered hook looks like this ==> textShadowBlur: [ "textShadow", 3 ], which consists of the subproperty's name, the associated root property's name, and the subproperty's position in the root's value. */ }, /* Convert the templates into individual hooks then append them to the registered object above. */ register: function () { /* Color hooks registration: Colors are defaulted to white -- as opposed to black -- since colors that are currently set to "transparent" default to their respective template below when color-animated, and white is typically a closer match to transparent than black is. An exception is made for text ("color"), which is almost always set closer to black than white. */ for (var i = 0; i < CSS.Lists.colors.length; i++) { var rgbComponents = (CSS.Lists.colors[i] === "color") ? "0 0 0 1" : "255 255 255 1"; CSS.Hooks.templates[CSS.Lists.colors[i]] = [ "Red Green Blue Alpha", rgbComponents ]; } var rootProperty, hookTemplate, hookNames; /* In IE, color values inside compound-value properties are positioned at the end the value instead of at the beginning. Thus, we re-arrange the templates accordingly. */ if (IE) { for (rootProperty in CSS.Hooks.templates) { hookTemplate = CSS.Hooks.templates[rootProperty]; hookNames = hookTemplate[0].split(" "); var defaultValues = hookTemplate[1].match(CSS.RegEx.valueSplit); if (hookNames[0] === "Color") { /* Reposition both the hook's name and its default value to the end of their respective strings. */ hookNames.push(hookNames.shift()); defaultValues.push(defaultValues.shift()); /* Replace the existing template for the hook's root property. */ CSS.Hooks.templates[rootProperty] = [ hookNames.join(" "), defaultValues.join(" ") ]; } } } /* Hook registration. */ for (rootProperty in CSS.Hooks.templates) { hookTemplate = CSS.Hooks.templates[rootProperty]; hookNames = hookTemplate[0].split(" "); for (var i in hookNames) { var fullHookName = rootProperty + hookNames[i], hookPosition = i; /* For each hook, register its full name (e.g. textShadowBlur) with its root property (e.g. textShadow) and the hook's position in its template's default value string. */ CSS.Hooks.registered[fullHookName] = [ rootProperty, hookPosition ]; } } }, /***************************** Injection and Extraction *****************************/ /* Look up the root property associated with the hook (e.g. return "textShadow" for "textShadowBlur"). */ /* Since a hook cannot be set directly (the browser won't recognize it), style updating for hooks is routed through the hook's root property. */ getRoot: function (property) { var hookData = CSS.Hooks.registered[property]; if (hookData) { return hookData[0]; } else { /* If there was no hook match, return the property name untouched. */ return property; } }, /* Convert any rootPropertyValue, null or otherwise, into a space-delimited list of hook values so that the targeted hook can be injected or extracted at its standard position. */ cleanRootPropertyValue: function(rootProperty, rootPropertyValue) { /* If the rootPropertyValue is wrapped with "rgb()", "clip()", etc., remove the wrapping to normalize the value before manipulation. */ if (CSS.RegEx.valueUnwrap.test(rootPropertyValue)) { rootPropertyValue = rootPropertyValue.match(CSS.RegEx.valueUnwrap)[1]; } /* If rootPropertyValue is a CSS null-value (from which there's inherently no hook value to extract), default to the root's default value as defined in CSS.Hooks.templates. */ /* Note: CSS null-values include "none", "auto", and "transparent". They must be converted into their zero-values (e.g. textShadow: "none" ==> textShadow: "0px 0px 0px black") for hook manipulation to proceed. */ if (CSS.Values.isCSSNullValue(rootPropertyValue)) { rootPropertyValue = CSS.Hooks.templates[rootProperty][1]; } return rootPropertyValue; }, /* Extracted the hook's value from its root property's value. This is used to get the starting value of an animating hook. */ extractValue: function (fullHookName, rootPropertyValue) { var hookData = CSS.Hooks.registered[fullHookName]; if (hookData) { var hookRoot = hookData[0], hookPosition = hookData[1]; rootPropertyValue = CSS.Hooks.cleanRootPropertyValue(hookRoot, rootPropertyValue); /* Split rootPropertyValue into its constituent hook values then grab the desired hook at its standard position. */ return rootPropertyValue.toString().match(CSS.RegEx.valueSplit)[hookPosition]; } else { /* If the provided fullHookName isn't a registered hook, return the rootPropertyValue that was passed in. */ return rootPropertyValue; } }, /* Inject the hook's value into its root property's value. This is used to piece back together the root property once Velocity has updated one of its individually hooked values through tweening. */ injectValue: function (fullHookName, hookValue, rootPropertyValue) { var hookData = CSS.Hooks.registered[fullHookName]; if (hookData) { var hookRoot = hookData[0], hookPosition = hookData[1], rootPropertyValueParts, rootPropertyValueUpdated; rootPropertyValue = CSS.Hooks.cleanRootPropertyValue(hookRoot, rootPropertyValue); /* Split rootPropertyValue into its individual hook values, replace the targeted value with hookValue, then reconstruct the rootPropertyValue string. */ rootPropertyValueParts = rootPropertyValue.toString().match(CSS.RegEx.valueSplit); rootPropertyValueParts[hookPosition] = hookValue; rootPropertyValueUpdated = rootPropertyValueParts.join(" "); return rootPropertyValueUpdated; } else { /* If the provided fullHookName isn't a registered hook, return the rootPropertyValue that was passed in. */ return rootPropertyValue; } } }, /******************* Normalizations *******************/ /* Normalizations standardize CSS property manipulation by pollyfilling browser-specific implementations (e.g. opacity) and reformatting special properties (e.g. clip, rgba) to look like standard ones. */ Normalizations: { /* Normalizations are passed a normalization target (either the property's name, its extracted value, or its injected value), the targeted element (which may need to be queried), and the targeted property value. */ registered: { clip: function (type, element, propertyValue) { switch (type) { case "name": return "clip"; /* Clip needs to be unwrapped and stripped of its commas during extraction. */ case "extract": var extracted; /* If Velocity also extracted this value, skip extraction. */ if (CSS.RegEx.wrappedValueAlreadyExtracted.test(propertyValue)) { extracted = propertyValue; } else { /* Remove the "rect()" wrapper. */ extracted = propertyValue.toString().match(CSS.RegEx.valueUnwrap); /* Strip off commas. */ extracted = extracted ? extracted[1].replace(/,(\s+)?/g, " ") : propertyValue; } return extracted; /* Clip needs to be re-wrapped during injection. */ case "inject": return "rect(" + propertyValue + ")"; } }, blur: function(type, element, propertyValue) { switch (type) { case "name": return Velocity.State.isFirefox ? "filter" : "-webkit-filter"; case "extract": var extracted = parseFloat(propertyValue); /* If extracted is NaN, meaning the value isn't already extracted. */ if (!(extracted || extracted === 0)) { var blurComponent = propertyValue.toString().match(/blur\(([0-9]+[A-z]+)\)/i); /* If the filter string had a blur component, return just the blur value and unit type. */ if (blurComponent) { extracted = blurComponent[1]; /* If the component doesn't exist, default blur to 0. */ } else { extracted = 0; } } return extracted; /* Blur needs to be re-wrapped during injection. */ case "inject": /* For the blur effect to be fully de-applied, it needs to be set to "none" instead of 0. */ if (!parseFloat(propertyValue)) { return "none"; } else { return "blur(" + propertyValue + ")"; } } }, /* <=IE8 do not support the standard opacity property. They use filter:alpha(opacity=INT) instead. */ opacity: function (type, element, propertyValue) { if (IE <= 8) { switch (type) { case "name": return "filter"; case "extract": /* <=IE8 return a "filter" value of "alpha(opacity=\d{1,3})". Extract the value and convert it to a decimal value to match the standard CSS opacity property's formatting. */ var extracted = propertyValue.toString().match(/alpha\(opacity=(.*)\)/i); if (extracted) { /* Convert to decimal value. */ propertyValue = extracted[1] / 100; } else { /* When extracting opacity, default to 1 since a null value means opacity hasn't been set. */ propertyValue = 1; } return propertyValue; case "inject": /* Opacified elements are required to have their zoom property set to a non-zero value. */ element.style.zoom = 1; /* Setting the filter property on elements with certain font property combinations can result in a highly unappealing ultra-bolding effect. There's no way to remedy this throughout a tween, but dropping the value altogether (when opacity hits 1) at leasts ensures that the glitch is gone post-tweening. */ if (parseFloat(propertyValue) >= 1) { return ""; } else { /* As per the filter property's spec, convert the decimal value to a whole number and wrap the value. */ return "alpha(opacity=" + parseInt(parseFloat(propertyValue) * 100, 10) + ")"; } } /* With all other browsers, normalization is not required; return the same values that were passed in. */ } else { switch (type) { case "name": return "opacity"; case "extract": return propertyValue; case "inject": return propertyValue; } } } }, /***************************** Batched Registrations *****************************/ /* Note: Batched normalizations extend the CSS.Normalizations.registered object. */ register: function () { /***************** Transforms *****************/ /* Transforms are the subproperties contained by the CSS "transform" property. Transforms must undergo normalization so that they can be referenced in a properties map by their individual names. */ /* Note: When transforms are "set", they are actually assigned to a per-element transformCache. When all transform setting is complete complete, CSS.flushTransformCache() must be manually called to flush the values to the DOM. Transform setting is batched in this way to improve performance: the transform style only needs to be updated once when multiple transform subproperties are being animated simultaneously. */ /* Note: IE9 and Android Gingerbread have support for 2D -- but not 3D -- transforms. Since animating unsupported transform properties results in the browser ignoring the *entire* transform string, we prevent these 3D values from being normalized for these browsers so that tweening skips these properties altogether (since it will ignore them as being unsupported by the browser.) */ if (!(IE <= 9) && !Velocity.State.isGingerbread) { /* Note: Since the standalone CSS "perspective" property and the CSS transform "perspective" subproperty share the same name, the latter is given a unique token within Velocity: "transformPerspective". */ CSS.Lists.transformsBase = CSS.Lists.transformsBase.concat(CSS.Lists.transforms3D); } for (var i = 0; i < CSS.Lists.transformsBase.length; i++) { /* Wrap the dynamically generated normalization function in a new scope so that transformName's value is paired with its respective function. (Otherwise, all functions would take the final for loop's transformName.) */ (function() { var transformName = CSS.Lists.transformsBase[i]; CSS.Normalizations.registered[transformName] = function (type, element, propertyValue) { switch (type) { /* The normalized property name is the parent "transform" property -- the property that is actually set in CSS. */ case "name": return "transform"; /* Transform values are cached onto a per-element transformCache object. */ case "extract": /* If this transform has yet to be assigned a value, return its null value. */ if (Data(element) === undefined || Data(element).transformCache[transformName] === undefined) { /* Scale CSS.Lists.transformsBase default to 1 whereas all other transform properties default to 0. */ return /^scale/i.test(transformName) ? 1 : 0; /* When transform values are set, they are wrapped in parentheses as per the CSS spec. Thus, when extracting their values (for tween calculations), we strip off the parentheses. */ } else { return Data(element).transformCache[transformName].replace(/[()]/g, ""); } case "inject": var invalid = false; /* If an individual transform property contains an unsupported unit type, the browser ignores the *entire* transform property. Thus, protect users from themselves by skipping setting for transform values supplied with invalid unit types. */ /* Switch on the base transform type; ignore the axis by removing the last letter from the transform's name. */ switch (transformName.substr(0, transformName.length - 1)) { /* Whitelist unit types for each transform. */ case "translate": invalid = !/(%|px|em|rem|vw|vh|\d)$/i.test(propertyValue); break; /* Since an axis-free "scale" property is supported as well, a little hack is used here to detect it by chopping off its last letter. */ case "scal": case "scale": /* Chrome on Android has a bug in which scaled elements blur if their initial scale value is below 1 (which can happen with forcefeeding). Thus, we detect a yet-unset scale property and ensure that its first value is always 1. More info: http://stackoverflow.com/questions/10417890/css3-animations-with-transform-causes-blurred-elements-on-webkit/10417962#10417962 */ if (Velocity.State.isAndroid && Data(element).transformCache[transformName] === undefined && propertyValue < 1) { propertyValue = 1; } invalid = !/(\d)$/i.test(propertyValue); break; case "skew": invalid = !/(deg|\d)$/i.test(propertyValue); break; case "rotate": invalid = !/(deg|\d)$/i.test(propertyValue); break; } if (!invalid) { /* As per the CSS spec, wrap the value in parentheses. */ Data(element).transformCache[transformName] = "(" + propertyValue + ")"; } /* Although the value is set on the transformCache object, return the newly-updated value for the calling code to process as normal. */ return Data(element).transformCache[transformName]; } }; })(); } /************* Colors *************/ /* Since Velocity only animates a single numeric value per property, color animation is achieved by hooking the individual RGBA components of CSS color properties. Accordingly, color values must be normalized (e.g. "#ff0000", "red", and "rgb(255, 0, 0)" ==> "255 0 0 1") so that their components can be injected/extracted by CSS.Hooks logic. */ for (var i = 0; i < CSS.Lists.colors.length; i++) { /* Wrap the dynamically generated normalization function in a new scope so that colorName's value is paired with its respective function. (Otherwise, all functions would take the final for loop's colorName.) */ (function () { var colorName = CSS.Lists.colors[i]; /* Note: In IE<=8, which support rgb but not rgba, color properties are reverted to rgb by stripping off the alpha component. */ CSS.Normalizations.registered[colorName] = function(type, element, propertyValue) { switch (type) { case "name": return colorName; /* Convert all color values into the rgb format. (Old IE can return hex values and color names instead of rgb/rgba.) */ case "extract": var extracted; /* If the color is already in its hookable form (e.g. "255 255 255 1") due to having been previously extracted, skip extraction. */ if (CSS.RegEx.wrappedValueAlreadyExtracted.test(propertyValue)) { extracted = propertyValue; } else { var converted, colorNames = { black: "rgb(0, 0, 0)", blue: "rgb(0, 0, 255)", gray: "rgb(128, 128, 128)", green: "rgb(0, 128, 0)", red: "rgb(255, 0, 0)", white: "rgb(255, 255, 255)" }; /* Convert color names to rgb. */ if (/^[A-z]+$/i.test(propertyValue)) { if (colorNames[propertyValue] !== undefined) { converted = colorNames[propertyValue] } else { /* If an unmatched color name is provided, default to black. */ converted = colorNames.black; } /* Convert hex values to rgb. */ } else if (CSS.RegEx.isHex.test(propertyValue)) { converted = "rgb(" + CSS.Values.hexToRgb(propertyValue).join(" ") + ")"; /* If the provided color doesn't match any of the accepted color formats, default to black. */ } else if (!(/^rgba?\(/i.test(propertyValue))) { converted = colorNames.black; } /* Remove the surrounding "rgb/rgba()" string then replace commas with spaces and strip repeated spaces (in case the value included spaces to begin with). */ extracted = (converted || propertyValue).toString().match(CSS.RegEx.valueUnwrap)[1].replace(/,(\s+)?/g, " "); } /* So long as this isn't <=IE8, add a fourth (alpha) component if it's missing and default it to 1 (visible). */ if (!(IE <= 8) && extracted.split(" ").length === 3) { extracted += " 1"; } return extracted; case "inject": /* If this is IE<=8 and an alpha component exists, strip it off. */ if (IE <= 8) { if (propertyValue.split(" ").length === 4) { propertyValue = propertyValue.split(/\s+/).slice(0, 3).join(" "); } /* Otherwise, add a fourth (alpha) component if it's missing and default it to 1 (visible). */ } else if (propertyValue.split(" ").length === 3) { propertyValue += " 1"; } /* Re-insert the browser-appropriate wrapper("rgb/rgba()"), insert commas, and strip off decimal units on all values but the fourth (R, G, and B only accept whole numbers). */ return (IE <= 8 ? "rgb" : "rgba") + "(" + propertyValue.replace(/\s+/g, ",").replace(/\.(\d)+(?=,)/g, "") + ")"; } }; })(); } } }, /************************ CSS Property Names ************************/ Names: { /* Camelcase a property name into its JavaScript notation (e.g. "background-color" ==> "backgroundColor"). Camelcasing is used to normalize property names between and across calls. */ camelCase: function (property) { return property.replace(/-(\w)/g, function (match, subMatch) { return subMatch.toUpperCase(); }); }, /* For SVG elements, some properties (namely, dimensional ones) are GET/SET via the element's HTML attributes (instead of via CSS styles). */ SVGAttribute: function (property) { var SVGAttributes = "width|height|x|y|cx|cy|r|rx|ry|x1|x2|y1|y2"; /* Certain browsers require an SVG transform to be applied as an attribute. (Otherwise, application via CSS is preferable due to 3D support.) */ if (IE || (Velocity.State.isAndroid && !Velocity.State.isChrome)) { SVGAttributes += "|transform"; } return new RegExp("^(" + SVGAttributes + ")$", "i").test(property); }, /* Determine whether a property should be set with a vendor prefix. */ /* If a prefixed version of the property exists, return it. Otherwise, return the original property name. If the property is not at all supported by the browser, return a false flag. */ prefixCheck: function (property) { /* If this property has already been checked, return the cached value. */ if (Velocity.State.prefixMatches[property]) { return [ Velocity.State.prefixMatches[property], true ]; } else { var vendors = [ "", "Webkit", "Moz", "ms", "O" ]; for (var i = 0, vendorsLength = vendors.length; i < vendorsLength; i++) { var propertyPrefixed; if (i === 0) { propertyPrefixed = property; } else { /* Capitalize the first letter of the property to conform to JavaScript vendor prefix notation (e.g. webkitFilter). */ propertyPrefixed = vendors[i] + property.replace(/^\w/, function(match) { return match.toUpperCase(); }); } /* Check if the browser supports this property as prefixed. */ if (Type.isString(Velocity.State.prefixElement.style[propertyPrefixed])) { /* Cache the match. */ Velocity.State.prefixMatches[property] = propertyPrefixed; return [ propertyPrefixed, true ]; } } /* If the browser doesn't support this property in any form, include a false flag so that the caller can decide how to proceed. */ return [ property, false ]; } } }, /************************ CSS Property Values ************************/ Values: { /* Hex to RGB conversion. Copyright Tim Down: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb */ hexToRgb: function (hex) { var shortformRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i, rgbParts; hex = hex.replace(shortformRegex, function (m, r, g, b) { return r + r + g + g + b + b; }); rgbParts = longformRegex.exec(hex); return rgbParts ? [ parseInt(rgbParts[1], 16), parseInt(rgbParts[2], 16), parseInt(rgbParts[3], 16) ] : [ 0, 0, 0 ]; }, isCSSNullValue: function (value) { /* The browser defaults CSS values that have not been set to either 0 or one of several possible null-value strings. Thus, we check for both falsiness and these special strings. */ /* Null-value checking is performed to default the special strings to 0 (for the sake of tweening) or their hook templates as defined as CSS.Hooks (for the sake of hook injection/extraction). */ /* Note: Chrome returns "rgba(0, 0, 0, 0)" for an undefined color whereas IE returns "transparent". */ return (value == 0 || /^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(value)); }, /* Retrieve a property's default unit type. Used for assigning a unit type when one is not supplied by the user. */ getUnitType: function (property) { if (/^(rotate|skew)/i.test(property)) { return "deg"; } else if (/(^(scale|scaleX|scaleY|scaleZ|alpha|flexGrow|flexHeight|zIndex|fontWeight)$)|((opacity|red|green|blue|alpha)$)/i.test(property)) { /* The above properties are unitless. */ return ""; } else { /* Default to px for all other properties. */ return "px"; } }, /* HTML elements default to an associated display type when they're not set to display:none. */ /* Note: This function is used for correctly setting the non-"none" display value in certain Velocity redirects, such as fadeIn/Out. */ getDisplayType: function (element) { var tagName = element && element.tagName.toString().toLowerCase(); if (/^(b|big|i|small|tt|abbr|acronym|cite|code|dfn|em|kbd|strong|samp|var|a|bdo|br|img|map|object|q|script|span|sub|sup|button|input|label|select|textarea)$/i.test(tagName)) { return "inline"; } else if (/^(li)$/i.test(tagName)) { return "list-item"; } else if (/^(tr)$/i.test(tagName)) { return "table-row"; } else if (/^(table)$/i.test(tagName)) { return "table"; } else if (/^(tbody)$/i.test(tagName)) { return "table-row-group"; /* Default to "block" when no match is found. */ } else { return "block"; } }, /* The class add/remove functions are used to temporarily apply a "velocity-animating" class to elements while they're animating. */ addClass: function (element, className) { if (element.classList) { element.classList.add(className); } else { element.className += (element.className.length ? " " : "") + className; } }, removeClass: function (element, className) { if (element.classList) { element.classList.remove(className); } else { element.className = element.className.toString().replace(new RegExp("(^|\\s)" + className.split(" ").join("|") + "(\\s|$)", "gi"), " "); } } }, /**************************** Style Getting & Setting ****************************/ /* The singular getPropertyValue, which routes the logic for all normalizations, hooks, and standard CSS properties. */ getPropertyValue: function (element, property, rootPropertyValue, forceStyleLookup) { /* Get an element's computed property value. */ /* Note: Retrieving the value of a CSS property cannot simply be performed by checking an element's style attribute (which only reflects user-defined values). Instead, the browser must be queried for a property's *computed* value. You can read more about getComputedStyle here: https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle */ function computePropertyValue (element, property) { /* When box-sizing isn't set to border-box, height and width style values are incorrectly computed when an element's scrollbars are visible (which expands the element's dimensions). Thus, we defer to the more accurate offsetHeight/Width property, which includes the total dimensions for interior, border, padding, and scrollbar. We subtract border and padding to get the sum of interior + scrollbar. */ var computedValue = 0; /* IE<=8 doesn't support window.getComputedStyle, thus we defer to jQuery, which has an extensive array of hacks to accurately retrieve IE8 property values. Re-implementing that logic here is not worth bloating the codebase for a dying browser. The performance repercussions of using jQuery here are minimal since Velocity is optimized to rarely (and sometimes never) query the DOM. Further, the $.css() codepath isn't that slow. */ if (IE <= 8) { computedValue = $.css(element, property); /* GET */ /* All other browsers support getComputedStyle. The returned live object reference is cached onto its associated element so that it does not need to be refetched upon every GET. */ } else { /* Browsers do not return height and width values for elements that are set to display:"none". Thus, we temporarily toggle display to the element type's default value. */ var toggleDisplay = false; if (/^(width|height)$/.test(property) && CSS.getPropertyValue(element, "display") === 0) { toggleDisplay = true; CSS.setPropertyValue(element, "display", CSS.Values.getDisplayType(element)); } function revertDisplay () { if (toggleDisplay) { CSS.setPropertyValue(element, "display", "none"); } } if (!forceStyleLookup) { if (property === "height" && CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() !== "border-box") { var contentBoxHeight = element.offsetHeight - (parseFloat(CSS.getPropertyValue(element, "borderTopWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "borderBottomWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingTop")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingBottom")) || 0); revertDisplay(); return contentBoxHeight; } else if (property === "width" && CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() !== "border-box") { var contentBoxWidth = element.offsetWidth - (parseFloat(CSS.getPropertyValue(element, "borderLeftWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "borderRightWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingLeft")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingRight")) || 0); revertDisplay(); return contentBoxWidth; } } var computedStyle; /* For elements that Velocity hasn't been called on directly (e.g. when Velocity queries the DOM on behalf of a parent of an element its animating), perform a direct getComputedStyle lookup since the object isn't cached. */ if (Data(element) === undefined) { computedStyle = window.getComputedStyle(element, null); /* GET */ /* If the computedStyle object has yet to be cached, do so now. */ } else if (!Data(element).computedStyle) { computedStyle = Data(element).computedStyle = window.getComputedStyle(element, null); /* GET */ /* If computedStyle is cached, use it. */ } else { computedStyle = Data(element).computedStyle; } /* IE and Firefox do not return a value for the generic borderColor -- they only return individual values for each border side's color. Also, in all browsers, when border colors aren't all the same, a compound value is returned that Velocity isn't setup to parse. So, as a polyfill for querying individual border side colors, we just return the top border's color and animate all borders from that value. */ if (property === "borderColor") { property = "borderTopColor"; } /* IE9 has a bug in which the "filter" property must be accessed from computedStyle using the getPropertyValue method instead of a direct property lookup. The getPropertyValue method is slower than a direct lookup, which is why we avoid it by default. */ if (IE === 9 && property === "filter") { computedValue = computedStyle.getPropertyValue(property); /* GET */ } else { computedValue = computedStyle[property]; } /* Fall back to the property's style value (if defined) when computedValue returns nothing, which can happen when the element hasn't been painted. */ if (computedValue === "" || computedValue === null) { computedValue = element.style[property]; } revertDisplay(); } /* For top, right, bottom, and left (TRBL) values that are set to "auto" on elements of "fixed" or "absolute" position, defer to jQuery for converting "auto" to a numeric value. (For elements with a "static" or "relative" position, "auto" has the same effect as being set to 0, so no conversion is necessary.) */ /* An example of why numeric conversion is necessary: When an element with "position:absolute" has an untouched "left" property, which reverts to "auto", left's value is 0 relative to its parent element, but is often non-zero relative to its *containing* (not parent) element, which is the nearest "position:relative" ancestor or the viewport (and always the viewport in the case of "position:fixed"). */ if (computedValue === "auto" && /^(top|right|bottom|left)$/i.test(property)) { var position = computePropertyValue(element, "position"); /* GET */ /* For absolute positioning, jQuery's $.position() only returns values for top and left; right and bottom will have their "auto" value reverted to 0. */ /* Note: A jQuery object must be created here since jQuery doesn't have a low-level alias for $.position(). Not a big deal since we're currently in a GET batch anyway. */ if (position === "fixed" || (position === "absolute" && /top|left/i.test(property))) { /* Note: jQuery strips the pixel unit from its returned values; we re-add it here to conform with computePropertyValue's behavior. */ computedValue = $(element).position()[property] + "px"; /* GET */ } } return computedValue; } var propertyValue; /* If this is a hooked property (e.g. "clipLeft" instead of the root property of "clip"), extract the hook's value from a normalized rootPropertyValue using CSS.Hooks.extractValue(). */ if (CSS.Hooks.registered[property]) { var hook = property, hookRoot = CSS.Hooks.getRoot(hook); /* If a cached rootPropertyValue wasn't passed in (which Velocity always attempts to do in order to avoid requerying the DOM), query the DOM for the root property's value. */ if (rootPropertyValue === undefined) { /* Since the browser is now being directly queried, use the official post-prefixing property name for this lookup. */ rootPropertyValue = CSS.getPropertyValue(element, CSS.Names.prefixCheck(hookRoot)[0]); /* GET */ } /* If this root has a normalization registered, peform the associated normalization extraction. */ if (CSS.Normalizations.registered[hookRoot]) { rootPropertyValue = CSS.Normalizations.registered[hookRoot]("extract", element, rootPropertyValue); } /* Extract the hook's value. */ propertyValue = CSS.Hooks.extractValue(hook, rootPropertyValue); /* If this is a normalized property (e.g. "opacity" becomes "filter" in <=IE8) or "translateX" becomes "transform"), normalize the property's name and value, and handle the special case of transforms. */ /* Note: Normalizing a property is mutually exclusive from hooking a property since hook-extracted values are strictly numerical and therefore do not require normalization extraction. */ } else if (CSS.Normalizations.registered[property]) { var normalizedPropertyName, normalizedPropertyValue; normalizedPropertyName = CSS.Normalizations.registered[property]("name", element); /* Transform values are calculated via normalization extraction (see below), which checks against the element's transformCache. At no point do transform GETs ever actually query the DOM; initial stylesheet values are never processed. This is because parsing 3D transform matrices is not always accurate and would bloat our codebase; thus, normalization extraction defaults initial transform values to their zero-values (e.g. 1 for scaleX and 0 for translateX). */ if (normalizedPropertyName !== "transform") { normalizedPropertyValue = computePropertyValue(element, CSS.Names.prefixCheck(normalizedPropertyName)[0]); /* GET */ /* If the value is a CSS null-value and this property has a hook template, use that zero-value template so that hooks can be extracted from it. */ if (CSS.Values.isCSSNullValue(normalizedPropertyValue) && CSS.Hooks.templates[property]) { normalizedPropertyValue = CSS.Hooks.templates[property][1]; } } propertyValue = CSS.Normalizations.registered[property]("extract", element, normalizedPropertyValue); } /* If a (numeric) value wasn't produced via hook extraction or normalization, query the DOM. */ if (!/^[\d-]/.test(propertyValue)) { /* For SVG elements, dimensional properties (which SVGAttribute() detects) are tweened via their HTML attribute values instead of their CSS style values. */ if (Data(element) && Data(element).isSVG && CSS.Names.SVGAttribute(property)) { /* Since the height/width attribute values must be set manually, they don't reflect computed values. Thus, we use use getBBox() to ensure we always get values for elements with undefined height/width attributes. */ if (/^(height|width)$/i.test(property)) { /* Firefox throws an error if .getBBox() is called on an SVG that isn't attached to the DOM. */ try { propertyValue = element.getBBox()[property]; } catch (error) { propertyValue = 0; } /* Otherwise, access the attribute value directly. */ } else { propertyValue = element.getAttribute(property); } } else { propertyValue = computePropertyValue(element, CSS.Names.prefixCheck(property)[0]); /* GET */ } } /* Since property lookups are for animation purposes (which entails computing the numeric delta between start and end values), convert CSS null-values to an integer of value 0. */ if (CSS.Values.isCSSNullValue(propertyValue)) { propertyValue = 0; } if (Velocity.debug >= 2) console.log("Get " + property + ": " + propertyValue); return propertyValue; }, /* The singular setPropertyValue, which routes the logic for all normalizations, hooks, and standard CSS properties. */ setPropertyValue: function(element, property, propertyValue, rootPropertyValue, scrollData) { var propertyName = property; /* In order to be subjected to call options and element queueing, scroll animation is routed through Velocity as if it were a standard CSS property. */ if (property === "scroll") { /* If a container option is present, scroll the container instead of the browser window. */ if (scrollData.container) { scrollData.container["scroll" + scrollData.direction] = propertyValue; /* Otherwise, Velocity defaults to scrolling the browser window. */ } else { if (scrollData.direction === "Left") { window.scrollTo(propertyValue, scrollData.alternateValue); } else { window.scrollTo(scrollData.alternateValue, propertyValue); } } } else { /* Transforms (translateX, rotateZ, etc.) are applied to a per-element transformCache object, which is manually flushed via flushTransformCache(). Thus, for now, we merely cache transforms being SET. */ if (CSS.Normalizations.registered[property] && CSS.Normalizations.registered[property]("name", element) === "transform") { /* Perform a normalization injection. */ /* Note: The normalization logic handles the transformCache updating. */ CSS.Normalizations.registered[property]("inject", element, propertyValue); propertyName = "transform"; propertyValue = Data(element).transformCache[property]; } else { /* Inject hooks. */ if (CSS.Hooks.registered[property]) { var hookName = property, hookRoot = CSS.Hooks.getRoot(property); /* If a cached rootPropertyValue was not provided, query the DOM for the hookRoot's current value. */ rootPropertyValue = rootPropertyValue || CSS.getPropertyValue(element, hookRoot); /* GET */ propertyValue = CSS.Hooks.injectValue(hookName, propertyValue, rootPropertyValue); property = hookRoot; } /* Normalize names and values. */ if (CSS.Normalizations.registered[property]) { propertyValue = CSS.Normalizations.registered[property]("inject", element, propertyValue); property = CSS.Normalizations.registered[property]("name", element); } /* Assign the appropriate vendor prefix before performing an official style update. */ propertyName = CSS.Names.prefixCheck(property)[0]; /* A try/catch is used for IE<=8, which throws an error when "invalid" CSS values are set, e.g. a negative width. Try/catch is avoided for other browsers since it incurs a performance overhead. */ if (IE <= 8) { try { element.style[propertyName] = propertyValue; } catch (error) { if (Velocity.debug) console.log("Browser does not support [" + propertyValue + "] for [" + propertyName + "]"); } /* SVG elements have their dimensional properties (width, height, x, y, cx, etc.) applied directly as attributes instead of as styles. */ /* Note: IE8 does not support SVG elements, so it's okay that we skip it for SVG animation. */ } else if (Data(element) && Data(element).isSVG && CSS.Names.SVGAttribute(property)) { /* Note: For SVG attributes, vendor-prefixed property names are never used. */ /* Note: Not all CSS properties can be animated via attributes, but the browser won't throw an error for unsupported properties. */ element.setAttribute(property, propertyValue); } else { element.style[propertyName] = propertyValue; } if (Velocity.debug >= 2) console.log("Set " + property + " (" + propertyName + "): " + propertyValue); } } /* Return the normalized property name and value in case the caller wants to know how these values were modified before being applied to the DOM. */ return [ propertyName, propertyValue ]; }, /* To increase performance by batching transform updates into a single SET, transforms are not directly applied to an element until flushTransformCache() is called. */ /* Note: Velocity applies transform properties in the same order that they are chronogically introduced to the element's CSS styles. */ flushTransformCache: function(element) { var transformString = ""; /* Certain browsers require that SVG transforms be applied as an attribute. However, the SVG transform attribute takes a modified version of CSS's transform string (units are dropped and, except for skewX/Y, subproperties are merged into their master property -- e.g. scaleX and scaleY are merged into scale(X Y). */ if ((IE || (Velocity.State.isAndroid && !Velocity.State.isChrome)) && Data(element).isSVG) { /* Since transform values are stored in their parentheses-wrapped form, we use a helper function to strip out their numeric values. Further, SVG transform properties only take unitless (representing pixels) values, so it's okay that parseFloat() strips the unit suffixed to the float value. */ function getTransformFloat (transformProperty) { return parseFloat(CSS.getPropertyValue(element, transformProperty)); } /* Create an object to organize all the transforms that we'll apply to the SVG element. To keep the logic simple, we process *all* transform properties -- even those that may not be explicitly applied (since they default to their zero-values anyway). */ var SVGTransforms = { translate: [ getTransformFloat("translateX"), getTransformFloat("translateY") ], skewX: [ getTransformFloat("skewX") ], skewY: [ getTransformFloat("skewY") ], /* If the scale property is set (non-1), use that value for the scaleX and scaleY values (this behavior mimics the result of animating all these properties at once on HTML elements). */ scale: getTransformFloat("scale") !== 1 ? [ getTransformFloat("scale"), getTransformFloat("scale") ] : [ getTransformFloat("scaleX"), getTransformFloat("scaleY") ], /* Note: SVG's rotate transform takes three values: rotation degrees followed by the X and Y values defining the rotation's origin point. We ignore the origin values (default them to 0). */ rotate: [ getTransformFloat("rotateZ"), 0, 0 ] }; /* Iterate through the transform properties in the user-defined property map order. (This mimics the behavior of non-SVG transform animation.) */ $.each(Data(element).transformCache, function(transformName) { /* Except for with skewX/Y, revert the axis-specific transform subproperties to their axis-free master properties so that they match up with SVG's accepted transform properties. */ if (/^translate/i.test(transformName)) { transformName = "translate"; } else if (/^scale/i.test(transformName)) { transformName = "scale"; } else if (/^rotate/i.test(transformName)) { transformName = "rotate"; } /* Check that we haven't yet deleted the property from the SVGTransforms container. */ if (SVGTransforms[transformName]) { /* Append the transform property in the SVG-supported transform format. As per the spec, surround the space-delimited values in parentheses. */ transformString += transformName + "(" + SVGTransforms[transformName].join(" ") + ")" + " "; /* After processing an SVG transform property, delete it from the SVGTransforms container so we don't re-insert the same master property if we encounter another one of its axis-specific properties. */ delete SVGTransforms[transformName]; } }); } else { var transformValue, perspective; /* Transform properties are stored as members of the transformCache object. Concatenate all the members into a string. */ $.each(Data(element).transformCache, function(transformName) { transformValue = Data(element).transformCache[transformName]; /* Transform's perspective subproperty must be set first in order to take effect. Store it temporarily. */ if (transformName === "transformPerspective") { perspective = transformValue; return true; } /* IE9 only supports one rotation type, rotateZ, which it refers to as "rotate". */ if (IE === 9 && transformName === "rotateZ") { transformName = "rotate"; } transformString += transformName + transformValue + " "; }); /* If present, set the perspective subproperty first. */ if (perspective) { transformString = "perspective" + perspective + " " + transformString; } } CSS.setPropertyValue(element, "transform", transformString); } }; /* Register hooks and normalizations. */ CSS.Hooks.register(); CSS.Normalizations.register(); /* Allow hook setting in the same fashion as jQuery's $.css(). */ Velocity.hook = function (elements, arg2, arg3) { var value = undefined; elements = sanitizeElements(elements); $.each(elements, function(i, element) { /* Initialize Velocity's per-element data cache if this element hasn't previously been animated. */ if (Data(element) === undefined) { Velocity.init(element); } /* Get property value. If an element set was passed in, only return the value for the first element. */ if (arg3 === undefined) { if (value === undefined) { value = Velocity.CSS.getPropertyValue(element, arg2); } /* Set property value. */ } else { /* sPV returns an array of the normalized propertyName/propertyValue pair used to update the DOM. */ var adjustedSet = Velocity.CSS.setPropertyValue(element, arg2, arg3); /* Transform properties don't automatically set. They have to be flushed to the DOM. */ if (adjustedSet[0] === "transform") { Velocity.CSS.flushTransformCache(element); } value = adjustedSet; } }); return value; }; /***************** Animation *****************/ var animate = function() { /****************** Call Chain ******************/ /* Logic for determining what to return to the call stack when exiting out of Velocity. */ function getChain () { /* If we are using the utility function, attempt to return this call's promise. If no promise library was detected, default to null instead of returning the targeted elements so that utility function's return value is standardized. */ if (isUtility) { return promiseData.promise || null; /* Otherwise, if we're using $.fn, return the jQuery-/Zepto-wrapped element set. */ } else { return elementsWrapped; } } /************************* Arguments Assignment *************************/ /* To allow for expressive CoffeeScript code, Velocity supports an alternative syntax in which "elements" (or "e"), "properties" (or "p"), and "options" (or "o") objects are defined on a container object that's passed in as Velocity's sole argument. */ /* Note: Some browsers automatically populate arguments with a "properties" object. We detect it by checking for its default "names" property. */ var syntacticSugar = (arguments[0] && (arguments[0].p || (($.isPlainObject(arguments[0].properties) && !arguments[0].properties.names) || Type.isString(arguments[0].properties)))), /* Whether Velocity was called via the utility function (as opposed to on a jQuery/Zepto object). */ isUtility, /* When Velocity is called via the utility function ($.Velocity()/Velocity()), elements are explicitly passed in as the first parameter. Thus, argument positioning varies. We normalize them here. */ elementsWrapped, argumentIndex; var elements, propertiesMap, options; /* Detect jQuery/Zepto elements being animated via the $.fn method. */ if (Type.isWrapped(this)) { isUtility = false; argumentIndex = 0; elements = this; elementsWrapped = this; /* Otherwise, raw elements are being animated via the utility function. */ } else { isUtility = true; argumentIndex = 1; elements = syntacticSugar ? (arguments[0].elements || arguments[0].e) : arguments[0]; } elements = sanitizeElements(elements); if (!elements) { return; } if (syntacticSugar) { propertiesMap = arguments[0].properties || arguments[0].p; options = arguments[0].options || arguments[0].o; } else { propertiesMap = arguments[argumentIndex]; options = arguments[argumentIndex + 1]; } /* The length of the element set (in the form of a nodeList or an array of elements) is defaulted to 1 in case a single raw DOM element is passed in (which doesn't contain a length property). */ var elementsLength = elements.length, elementsIndex = 0; /*************************** Argument Overloading ***************************/ /* Support is included for jQuery's argument overloading: $.animate(propertyMap [, duration] [, easing] [, complete]). Overloading is detected by checking for the absence of an object being passed into options. */ /* Note: The stop and finish actions do not accept animation options, and are therefore excluded from this check. */ if (!/^(stop|finish|finishAll)$/i.test(propertiesMap) && !$.isPlainObject(options)) { /* The utility function shifts all arguments one position to the right, so we adjust for that offset. */ var startingArgumentPosition = argumentIndex + 1; options = {}; /* Iterate through all options arguments */ for (var i = startingArgumentPosition; i < arguments.length; i++) { /* Treat a number as a duration. Parse it out. */ /* Note: The following RegEx will return true if passed an array with a number as its first item. Thus, arrays are skipped from this check. */ if (!Type.isArray(arguments[i]) && (/^(fast|normal|slow)$/i.test(arguments[i]) || /^\d/.test(arguments[i]))) { options.duration = arguments[i]; /* Treat strings and arrays as easings. */ } else if (Type.isString(arguments[i]) || Type.isArray(arguments[i])) { options.easing = arguments[i]; /* Treat a function as a complete callback. */ } else if (Type.isFunction(arguments[i])) { options.complete = arguments[i]; } } } /*************** Promises ***************/ var promiseData = { promise: null, resolver: null, rejecter: null }; /* If this call was made via the utility function (which is the default method of invocation when jQuery/Zepto are not being used), and if promise support was detected, create a promise object for this call and store references to its resolver and rejecter methods. The resolve method is used when a call completes naturally or is prematurely stopped by the user. In both cases, completeCall() handles the associated call cleanup and promise resolving logic. The reject method is used when an invalid set of arguments is passed into a Velocity call. */ /* Note: Velocity employs a call-based queueing architecture, which means that stopping an animating element actually stops the full call that triggered it -- not that one element exclusively. Similarly, there is one promise per call, and all elements targeted by a Velocity call are grouped together for the purposes of resolving and rejecting a promise. */ if (isUtility && Velocity.Promise) { promiseData.promise = new Velocity.Promise(function (resolve, reject) { promiseData.resolver = resolve; promiseData.rejecter = reject; }); } /********************* Action Detection *********************/ /* Velocity's behavior is categorized into "actions": Elements can either be specially scrolled into view, or they can be started, stopped, or reversed. If a literal or referenced properties map is passed in as Velocity's first argument, the associated action is "start". Alternatively, "scroll", "reverse", or "stop" can be passed in instead of a properties map. */ var action; switch (propertiesMap) { case "scroll": action = "scroll"; break; case "reverse": action = "reverse"; break; case "finish": case "finishAll": case "stop": /******************* Action: Stop *******************/ /* Clear the currently-active delay on each targeted element. */ $.each(elements, function(i, element) { if (Data(element) && Data(element).delayTimer) { /* Stop the timer from triggering its cached next() function. */ clearTimeout(Data(element).delayTimer.setTimeout); /* Manually call the next() function so that the subsequent queue items can progress. */ if (Data(element).delayTimer.next) { Data(element).delayTimer.next(); } delete Data(element).delayTimer; } /* If we want to finish everything in the queue, we have to iterate through it and call each function. This will make them active calls below, which will cause them to be applied via the duration setting. */ if (propertiesMap === "finishAll" && (options === true || Type.isString(options))) { /* Iterate through the items in the element's queue. */ $.each($.queue(element, Type.isString(options) ? options : ""), function(_, item) { /* The queue array can contain an "inprogress" string, which we skip. */ if (Type.isFunction(item)) { item(); } }); /* Clearing the $.queue() array is achieved by resetting it to []. */ $.queue(element, Type.isString(options) ? options : "", []); } }); var callsToStop = []; /* When the stop action is triggered, the elements' currently active call is immediately stopped. The active call might have been applied to multiple elements, in which case all of the call's elements will be stopped. When an element is stopped, the next item in its animation queue is immediately triggered. */ /* An additional argument may be passed in to clear an element's remaining queued calls. Either true (which defaults to the "fx" queue) or a custom queue string can be passed in. */ /* Note: The stop command runs prior to Velocity's Queueing phase since its behavior is intended to take effect *immediately*, regardless of the element's current queue state. */ /* Iterate through every active call. */ $.each(Velocity.State.calls, function(i, activeCall) { /* Inactive calls are set to false by the logic inside completeCall(). Skip them. */ if (activeCall) { /* Iterate through the active call's targeted elements. */ $.each(activeCall[1], function(k, activeElement) { /* If true was passed in as a secondary argument, clear absolutely all calls on this element. Otherwise, only clear calls associated with the relevant queue. */ /* Call stopping logic works as follows: - options === true --> stop current default queue calls (and queue:false calls), including remaining queued ones. - options === undefined --> stop current queue:"" call and all queue:false calls. - options === false --> stop only queue:false calls. - options === "custom" --> stop current queue:"custom" call, including remaining queued ones (there is no functionality to only clear the currently-running queue:"custom" call). */ var queueName = (options === undefined) ? "" : options; if (queueName !== true && (activeCall[2].queue !== queueName) && !(options === undefined && activeCall[2].queue === false)) { return true; } /* Iterate through the calls targeted by the stop command. */ $.each(elements, function(l, element) { /* Check that this call was applied to the target element. */ if (element === activeElement) { /* Optionally clear the remaining queued calls. If we're doing "finishAll" this won't find anything, due to the queue-clearing above. */ if (options === true || Type.isString(options)) { /* Iterate through the items in the element's queue. */ $.each($.queue(element, Type.isString(options) ? options : ""), function(_, item) { /* The queue array can contain an "inprogress" string, which we skip. */ if (Type.isFunction(item)) { /* Pass the item's callback a flag indicating that we want to abort from the queue call. (Specifically, the queue will resolve the call's associated promise then abort.) */ item(null, true); } }); /* Clearing the $.queue() array is achieved by resetting it to []. */ $.queue(element, Type.isString(options) ? options : "", []); } if (propertiesMap === "stop") { /* Since "reverse" uses cached start values (the previous call's endValues), these values must be changed to reflect the final value that the elements were actually tweened to. */ /* Note: If only queue:false animations are currently running on an element, it won't have a tweensContainer object. Also, queue:false animations can't be reversed. */ if (Data(element) && Data(element).tweensContainer && queueName !== false) { $.each(Data(element).tweensContainer, function(m, activeTween) { activeTween.endValue = activeTween.currentValue; }); } callsToStop.push(i); } else if (propertiesMap === "finish" || propertiesMap === "finishAll") { /* To get active tweens to finish immediately, we forcefully shorten their durations to 1ms so that they finish upon the next rAf tick then proceed with normal call completion logic. */ activeCall[2].duration = 1; } } }); }); } }); /* Prematurely call completeCall() on each matched active call. Pass an additional flag for "stop" to indicate that the complete callback and display:none setting should be skipped since we're completing prematurely. */ if (propertiesMap === "stop") { $.each(callsToStop, function(i, j) { completeCall(j, true); }); if (promiseData.promise) { /* Immediately resolve the promise associated with this stop call since stop runs synchronously. */ promiseData.resolver(elements); } } /* Since we're stopping, and not proceeding with queueing, exit out of Velocity. */ return getChain(); default: /* Treat a non-empty plain object as a literal properties map. */ if ($.isPlainObject(propertiesMap) && !Type.isEmptyObject(propertiesMap)) { action = "start"; /**************** Redirects ****************/ /* Check if a string matches a registered redirect (see Redirects above). */ } else if (Type.isString(propertiesMap) && Velocity.Redirects[propertiesMap]) { var opts = $.extend({}, options), durationOriginal = opts.duration, delayOriginal = opts.delay || 0; /* If the backwards option was passed in, reverse the element set so that elements animate from the last to the first. */ if (opts.backwards === true) { elements = $.extend(true, [], elements).reverse(); } /* Individually trigger the redirect for each element in the set to prevent users from having to handle iteration logic in their redirect. */ $.each(elements, function(elementIndex, element) { /* If the stagger option was passed in, successively delay each element by the stagger value (in ms). Retain the original delay value. */ if (parseFloat(opts.stagger)) { opts.delay = delayOriginal + (parseFloat(opts.stagger) * elementIndex); } else if (Type.isFunction(opts.stagger)) { opts.delay = delayOriginal + opts.stagger.call(element, elementIndex, elementsLength); } /* If the drag option was passed in, successively increase/decrease (depending on the presense of opts.backwards) the duration of each element's animation, using floors to prevent producing very short durations. */ if (opts.drag) { /* Default the duration of UI pack effects (callouts and transitions) to 1000ms instead of the usual default duration of 400ms. */ opts.duration = parseFloat(durationOriginal) || (/^(callout|transition)/.test(propertiesMap) ? 1000 : DURATION_DEFAULT); /* For each element, take the greater duration of: A) animation completion percentage relative to the original duration, B) 75% of the original duration, or C) a 200ms fallback (in case duration is already set to a low value). The end result is a baseline of 75% of the redirect's duration that increases/decreases as the end of the element set is approached. */ opts.duration = Math.max(opts.duration * (opts.backwards ? 1 - elementIndex/elementsLength : (elementIndex + 1) / elementsLength), opts.duration * 0.75, 200); } /* Pass in the call's opts object so that the redirect can optionally extend it. It defaults to an empty object instead of null to reduce the opts checking logic required inside the redirect. */ Velocity.Redirects[propertiesMap].call(element, element, opts || {}, elementIndex, elementsLength, elements, promiseData.promise ? promiseData : undefined); }); /* Since the animation logic resides within the redirect's own code, abort the remainder of this call. (The performance overhead up to this point is virtually non-existant.) */ /* Note: The jQuery call chain is kept intact by returning the complete element set. */ return getChain(); } else { var abortError = "Velocity: First argument (" + propertiesMap + ") was not a property map, a known action, or a registered redirect. Aborting."; if (promiseData.promise) { promiseData.rejecter(new Error(abortError)); } else { console.log(abortError); } return getChain(); } } /************************** Call-Wide Variables **************************/ /* A container for CSS unit conversion ratios (e.g. %, rem, and em ==> px) that is used to cache ratios across all elements being animated in a single Velocity call. Calculating unit ratios necessitates DOM querying and updating, and is therefore avoided (via caching) wherever possible. This container is call-wide instead of page-wide to avoid the risk of using stale conversion metrics across Velocity animations that are not immediately consecutively chained. */ var callUnitConversionData = { lastParent: null, lastPosition: null, lastFontSize: null, lastPercentToPxWidth: null, lastPercentToPxHeight: null, lastEmToPx: null, remToPx: null, vwToPx: null, vhToPx: null }; /* A container for all the ensuing tween data and metadata associated with this call. This container gets pushed to the page-wide Velocity.State.calls array that is processed during animation ticking. */ var call = []; /************************ Element Processing ************************/ /* Element processing consists of three parts -- data processing that cannot go stale and data processing that *can* go stale (i.e. third-party style modifications): 1) Pre-Queueing: Element-wide variables, including the element's data storage, are instantiated. Call options are prepared. If triggered, the Stop action is executed. 2) Queueing: The logic that runs once this call has reached its point of execution in the element's $.queue() stack. Most logic is placed here to avoid risking it becoming stale. 3) Pushing: Consolidation of the tween data followed by its push onto the global in-progress calls container. */ function processElement () { /************************* Part I: Pre-Queueing *************************/ /*************************** Element-Wide Variables ***************************/ var element = this, /* The runtime opts object is the extension of the current call's options and Velocity's page-wide option defaults. */ opts = $.extend({}, Velocity.defaults, options), /* A container for the processed data associated with each property in the propertyMap. (Each property in the map produces its own "tween".) */ tweensContainer = {}, elementUnitConversionData; /****************** Element Init ******************/ if (Data(element) === undefined) { Velocity.init(element); } /****************** Option: Delay ******************/ /* Since queue:false doesn't respect the item's existing queue, we avoid injecting its delay here (it's set later on). */ /* Note: Velocity rolls its own delay function since jQuery doesn't have a utility alias for $.fn.delay() (and thus requires jQuery element creation, which we avoid since its overhead includes DOM querying). */ if (parseFloat(opts.delay) && opts.queue !== false) { $.queue(element, opts.queue, function(next) { /* This is a flag used to indicate to the upcoming completeCall() function that this queue entry was initiated by Velocity. See completeCall() for further details. */ Velocity.velocityQueueEntryFlag = true; /* The ensuing queue item (which is assigned to the "next" argument that $.queue() automatically passes in) will be triggered after a setTimeout delay. The setTimeout is stored so that it can be subjected to clearTimeout() if this animation is prematurely stopped via Velocity's "stop" command. */ Data(element).delayTimer = { setTimeout: setTimeout(next, parseFloat(opts.delay)), next: next }; }); } /********************* Option: Duration *********************/ /* Support for jQuery's named durations. */ switch (opts.duration.toString().toLowerCase()) { case "fast": opts.duration = 200; break; case "normal": opts.duration = DURATION_DEFAULT; break; case "slow": opts.duration = 600; break; default: /* Remove the potential "ms" suffix and default to 1 if the user is attempting to set a duration of 0 (in order to produce an immediate style change). */ opts.duration = parseFloat(opts.duration) || 1; } /************************ Global Option: Mock ************************/ if (Velocity.mock !== false) { /* In mock mode, all animations are forced to 1ms so that they occur immediately upon the next rAF tick. Alternatively, a multiplier can be passed in to time remap all delays and durations. */ if (Velocity.mock === true) { opts.duration = opts.delay = 1; } else { opts.duration *= parseFloat(Velocity.mock) || 1; opts.delay *= parseFloat(Velocity.mock) || 1; } } /******************* Option: Easing *******************/ opts.easing = getEasing(opts.easing, opts.duration); /********************** Option: Callbacks **********************/ /* Callbacks must functions. Otherwise, default to null. */ if (opts.begin && !Type.isFunction(opts.begin)) { opts.begin = null; } if (opts.progress && !Type.isFunction(opts.progress)) { opts.progress = null; } if (opts.complete && !Type.isFunction(opts.complete)) { opts.complete = null; } /********************************* Option: Display & Visibility *********************************/ /* Refer to Velocity's documentation (VelocityJS.org/#displayAndVisibility) for a description of the display and visibility options' behavior. */ /* Note: We strictly check for undefined instead of falsiness because display accepts an empty string value. */ if (opts.display !== undefined && opts.display !== null) { opts.display = opts.display.toString().toLowerCase(); /* Users can pass in a special "auto" value to instruct Velocity to set the element to its default display value. */ if (opts.display === "auto") { opts.display = Velocity.CSS.Values.getDisplayType(element); } } if (opts.visibility !== undefined && opts.visibility !== null) { opts.visibility = opts.visibility.toString().toLowerCase(); } /********************** Option: mobileHA **********************/ /* When set to true, and if this is a mobile device, mobileHA automatically enables hardware acceleration (via a null transform hack) on animating elements. HA is removed from the element at the completion of its animation. */ /* Note: Android Gingerbread doesn't support HA. If a null transform hack (mobileHA) is in fact set, it will prevent other tranform subproperties from taking effect. */ /* Note: You can read more about the use of mobileHA in Velocity's documentation: VelocityJS.org/#mobileHA. */ opts.mobileHA = (opts.mobileHA && Velocity.State.isMobile && !Velocity.State.isGingerbread); /*********************** Part II: Queueing ***********************/ /* When a set of elements is targeted by a Velocity call, the set is broken up and each element has the current Velocity call individually queued onto it. In this way, each element's existing queue is respected; some elements may already be animating and accordingly should not have this current Velocity call triggered immediately. */ /* In each queue, tween data is processed for each animating property then pushed onto the call-wide calls array. When the last element in the set has had its tweens processed, the call array is pushed to Velocity.State.calls for live processing by the requestAnimationFrame tick. */ function buildQueue (next) { /******************* Option: Begin *******************/ /* The begin callback is fired once per call -- not once per elemenet -- and is passed the full raw DOM element set as both its context and its first argument. */ if (opts.begin && elementsIndex === 0) { /* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */ try { opts.begin.call(elements, elements); } catch (error) { setTimeout(function() { throw error; }, 1); } } /***************************************** Tween Data Construction (for Scroll) *****************************************/ /* Note: In order to be subjected to chaining and animation options, scroll's tweening is routed through Velocity as if it were a standard CSS property animation. */ if (action === "scroll") { /* The scroll action uniquely takes an optional "offset" option -- specified in pixels -- that offsets the targeted scroll position. */ var scrollDirection = (/^x$/i.test(opts.axis) ? "Left" : "Top"), scrollOffset = parseFloat(opts.offset) || 0, scrollPositionCurrent, scrollPositionCurrentAlternate, scrollPositionEnd; /* Scroll also uniquely takes an optional "container" option, which indicates the parent element that should be scrolled -- as opposed to the browser window itself. This is useful for scrolling toward an element that's inside an overflowing parent element. */ if (opts.container) { /* Ensure that either a jQuery object or a raw DOM element was passed in. */ if (Type.isWrapped(opts.container) || Type.isNode(opts.container)) { /* Extract the raw DOM element from the jQuery wrapper. */ opts.container = opts.container[0] || opts.container; /* Note: Unlike other properties in Velocity, the browser's scroll position is never cached since it so frequently changes (due to the user's natural interaction with the page). */ scrollPositionCurrent = opts.container["scroll" + scrollDirection]; /* GET */ /* $.position() values are relative to the container's currently viewable area (without taking into account the container's true dimensions -- say, for example, if the container was not overflowing). Thus, the scroll end value is the sum of the child element's position *and* the scroll container's current scroll position. */ scrollPositionEnd = (scrollPositionCurrent + $(element).position()[scrollDirection.toLowerCase()]) + scrollOffset; /* GET */ /* If a value other than a jQuery object or a raw DOM element was passed in, default to null so that this option is ignored. */ } else { opts.container = null; } } else { /* If the window itself is being scrolled -- not a containing element -- perform a live scroll position lookup using the appropriate cached property names (which differ based on browser type). */ scrollPositionCurrent = Velocity.State.scrollAnchor[Velocity.State["scrollProperty" + scrollDirection]]; /* GET */ /* When scrolling the browser window, cache the alternate axis's current value since window.scrollTo() doesn't let us change only one value at a time. */ scrollPositionCurrentAlternate = Velocity.State.scrollAnchor[Velocity.State["scrollProperty" + (scrollDirection === "Left" ? "Top" : "Left")]]; /* GET */ /* Unlike $.position(), $.offset() values are relative to the browser window's true dimensions -- not merely its currently viewable area -- and therefore end values do not need to be compounded onto current values. */ scrollPositionEnd = $(element).offset()[scrollDirection.toLowerCase()] + scrollOffset; /* GET */ } /* Since there's only one format that scroll's associated tweensContainer can take, we create it manually. */ tweensContainer = { scroll: { rootPropertyValue: false, startValue: scrollPositionCurrent, currentValue: scrollPositionCurrent, endValue: scrollPositionEnd, unitType: "", easing: opts.easing, scrollData: { container: opts.container, direction: scrollDirection, alternateValue: scrollPositionCurrentAlternate } }, element: element }; if (Velocity.debug) console.log("tweensContainer (scroll): ", tweensContainer.scroll, element); /****************************************** Tween Data Construction (for Reverse) ******************************************/ /* Reverse acts like a "start" action in that a property map is animated toward. The only difference is that the property map used for reverse is the inverse of the map used in the previous call. Thus, we manipulate the previous call to construct our new map: use the previous map's end values as our new map's start values. Copy over all other data. */ /* Note: Reverse can be directly called via the "reverse" parameter, or it can be indirectly triggered via the loop option. (Loops are composed of multiple reverses.) */ /* Note: Reverse calls do not need to be consecutively chained onto a currently-animating element in order to operate on cached values; there is no harm to reverse being called on a potentially stale data cache since reverse's behavior is simply defined as reverting to the element's values as they were prior to the previous *Velocity* call. */ } else if (action === "reverse") { /* Abort if there is no prior animation data to reverse to. */ if (!Data(element).tweensContainer) { /* Dequeue the element so that this queue entry releases itself immediately, allowing subsequent queue entries to run. */ $.dequeue(element, opts.queue); return; } else { /********************* Options Parsing *********************/ /* If the element was hidden via the display option in the previous call, revert display to "auto" prior to reversal so that the element is visible again. */ if (Data(element).opts.display === "none") { Data(element).opts.display = "auto"; } if (Data(element).opts.visibility === "hidden") { Data(element).opts.visibility = "visible"; } /* If the loop option was set in the previous call, disable it so that "reverse" calls aren't recursively generated. Further, remove the previous call's callback options; typically, users do not want these to be refired. */ Data(element).opts.loop = false; Data(element).opts.begin = null; Data(element).opts.complete = null; /* Since we're extending an opts object that has already been extended with the defaults options object, we remove non-explicitly-defined properties that are auto-assigned values. */ if (!options.easing) { delete opts.easing; } if (!options.duration) { delete opts.duration; } /* The opts object used for reversal is an extension of the options object optionally passed into this reverse call plus the options used in the previous Velocity call. */ opts = $.extend({}, Data(element).opts, opts); /************************************* Tweens Container Reconstruction *************************************/ /* Create a deepy copy (indicated via the true flag) of the previous call's tweensContainer. */ var lastTweensContainer = $.extend(true, {}, Data(element).tweensContainer); /* Manipulate the previous tweensContainer by replacing its end values and currentValues with its start values. */ for (var lastTween in lastTweensContainer) { /* In addition to tween data, tweensContainers contain an element property that we ignore here. */ if (lastTween !== "element") { var lastStartValue = lastTweensContainer[lastTween].startValue; lastTweensContainer[lastTween].startValue = lastTweensContainer[lastTween].currentValue = lastTweensContainer[lastTween].endValue; lastTweensContainer[lastTween].endValue = lastStartValue; /* Easing is the only option that embeds into the individual tween data (since it can be defined on a per-property basis). Accordingly, every property's easing value must be updated when an options object is passed in with a reverse call. The side effect of this extensibility is that all per-property easing values are forcefully reset to the new value. */ if (!Type.isEmptyObject(options)) { lastTweensContainer[lastTween].easing = opts.easing; } if (Velocity.debug) console.log("reverse tweensContainer (" + lastTween + "): " + JSON.stringify(lastTweensContainer[lastTween]), element); } } tweensContainer = lastTweensContainer; } /***************************************** Tween Data Construction (for Start) *****************************************/ } else if (action === "start") { /************************* Value Transferring *************************/ /* If this queue entry follows a previous Velocity-initiated queue entry *and* if this entry was created while the element was in the process of being animated by Velocity, then this current call is safe to use the end values from the prior call as its start values. Velocity attempts to perform this value transfer process whenever possible in order to avoid requerying the DOM. */ /* If values aren't transferred from a prior call and start values were not forcefed by the user (more on this below), then the DOM is queried for the element's current values as a last resort. */ /* Note: Conversely, animation reversal (and looping) *always* perform inter-call value transfers; they never requery the DOM. */ var lastTweensContainer; /* The per-element isAnimating flag is used to indicate whether it's safe (i.e. the data isn't stale) to transfer over end values to use as start values. If it's set to true and there is a previous Velocity call to pull values from, do so. */ if (Data(element).tweensContainer && Data(element).isAnimating === true) { lastTweensContainer = Data(element).tweensContainer; } /*************************** Tween Data Calculation ***************************/ /* This function parses property data and defaults endValue, easing, and startValue as appropriate. */ /* Property map values can either take the form of 1) a single value representing the end value, or 2) an array in the form of [ endValue, [, easing] [, startValue] ]. The optional third parameter is a forcefed startValue to be used instead of querying the DOM for the element's current value. Read Velocity's docmentation to learn more about forcefeeding: VelocityJS.org/#forcefeeding */ function parsePropertyValue (valueData, skipResolvingEasing) { var endValue = undefined, easing = undefined, startValue = undefined; /* Handle the array format, which can be structured as one of three potential overloads: A) [ endValue, easing, startValue ], B) [ endValue, easing ], or C) [ endValue, startValue ] */ if (Type.isArray(valueData)) { /* endValue is always the first item in the array. Don't bother validating endValue's value now since the ensuing property cycling logic does that. */ endValue = valueData[0]; /* Two-item array format: If the second item is a number, function, or hex string, treat it as a start value since easings can only be non-hex strings or arrays. */ if ((!Type.isArray(valueData[1]) && /^[\d-]/.test(valueData[1])) || Type.isFunction(valueData[1]) || CSS.RegEx.isHex.test(valueData[1])) { startValue = valueData[1]; /* Two or three-item array: If the second item is a non-hex string or an array, treat it as an easing. */ } else if ((Type.isString(valueData[1]) && !CSS.RegEx.isHex.test(valueData[1])) || Type.isArray(valueData[1])) { easing = skipResolvingEasing ? valueData[1] : getEasing(valueData[1], opts.duration); /* Don't bother validating startValue's value now since the ensuing property cycling logic inherently does that. */ if (valueData[2] !== undefined) { startValue = valueData[2]; } } /* Handle the single-value format. */ } else { endValue = valueData; } /* Default to the call's easing if a per-property easing type was not defined. */ if (!skipResolvingEasing) { easing = easing || opts.easing; } /* If functions were passed in as values, pass the function the current element as its context, plus the element's index and the element set's size as arguments. Then, assign the returned value. */ if (Type.isFunction(endValue)) { endValue = endValue.call(element, elementsIndex, elementsLength); } if (Type.isFunction(startValue)) { startValue = startValue.call(element, elementsIndex, elementsLength); } /* Allow startValue to be left as undefined to indicate to the ensuing code that its value was not forcefed. */ return [ endValue || 0, easing, startValue ]; } /* Cycle through each property in the map, looking for shorthand color properties (e.g. "color" as opposed to "colorRed"). Inject the corresponding colorRed, colorGreen, and colorBlue RGB component tweens into the propertiesMap (which Velocity understands) and remove the shorthand property. */ $.each(propertiesMap, function(property, value) { /* Find shorthand color properties that have been passed a hex string. */ if (RegExp("^" + CSS.Lists.colors.join("$|^") + "$").test(property)) { /* Parse the value data for each shorthand. */ var valueData = parsePropertyValue(value, true), endValue = valueData[0], easing = valueData[1], startValue = valueData[2]; if (CSS.RegEx.isHex.test(endValue)) { /* Convert the hex strings into their RGB component arrays. */ var colorComponents = [ "Red", "Green", "Blue" ], endValueRGB = CSS.Values.hexToRgb(endValue), startValueRGB = startValue ? CSS.Values.hexToRgb(startValue) : undefined; /* Inject the RGB component tweens into propertiesMap. */ for (var i = 0; i < colorComponents.length; i++) { var dataArray = [ endValueRGB[i] ]; if (easing) { dataArray.push(easing); } if (startValueRGB !== undefined) { dataArray.push(startValueRGB[i]); } propertiesMap[property + colorComponents[i]] = dataArray; } /* Remove the intermediary shorthand property entry now that we've processed it. */ delete propertiesMap[property]; } } }); /* Create a tween out of each property, and append its associated data to tweensContainer. */ for (var property in propertiesMap) { /************************** Start Value Sourcing **************************/ /* Parse out endValue, easing, and startValue from the property's data. */ var valueData = parsePropertyValue(propertiesMap[property]), endValue = valueData[0], easing = valueData[1], startValue = valueData[2]; /* Now that the original property name's format has been used for the parsePropertyValue() lookup above, we force the property to its camelCase styling to normalize it for manipulation. */ property = CSS.Names.camelCase(property); /* In case this property is a hook, there are circumstances where we will intend to work on the hook's root property and not the hooked subproperty. */ var rootProperty = CSS.Hooks.getRoot(property), rootPropertyValue = false; /* Other than for the dummy tween property, properties that are not supported by the browser (and do not have an associated normalization) will inherently produce no style changes when set, so they are skipped in order to decrease animation tick overhead. Property support is determined via prefixCheck(), which returns a false flag when no supported is detected. */ /* Note: Since SVG elements have some of their properties directly applied as HTML attributes, there is no way to check for their explicit browser support, and so we skip skip this check for them. */ if (!Data(element).isSVG && rootProperty !== "tween" && CSS.Names.prefixCheck(rootProperty)[1] === false && CSS.Normalizations.registered[rootProperty] === undefined) { if (Velocity.debug) console.log("Skipping [" + rootProperty + "] due to a lack of browser support."); continue; } /* If the display option is being set to a non-"none" (e.g. "block") and opacity (filter on IE<=8) is being animated to an endValue of non-zero, the user's intention is to fade in from invisible, thus we forcefeed opacity a startValue of 0 if its startValue hasn't already been sourced by value transferring or prior forcefeeding. */ if (((opts.display !== undefined && opts.display !== null && opts.display !== "none") || (opts.visibility !== undefined && opts.visibility !== "hidden")) && /opacity|filter/.test(property) && !startValue && endValue !== 0) { startValue = 0; } /* If values have been transferred from the previous Velocity call, extract the endValue and rootPropertyValue for all of the current call's properties that were *also* animated in the previous call. */ /* Note: Value transferring can optionally be disabled by the user via the _cacheValues option. */ if (opts._cacheValues && lastTweensContainer && lastTweensContainer[property]) { if (startValue === undefined) { startValue = lastTweensContainer[property].endValue + lastTweensContainer[property].unitType; } /* The previous call's rootPropertyValue is extracted from the element's data cache since that's the instance of rootPropertyValue that gets freshly updated by the tweening process, whereas the rootPropertyValue attached to the incoming lastTweensContainer is equal to the root property's value prior to any tweening. */ rootPropertyValue = Data(element).rootPropertyValueCache[rootProperty]; /* If values were not transferred from a previous Velocity call, query the DOM as needed. */ } else { /* Handle hooked properties. */ if (CSS.Hooks.registered[property]) { if (startValue === undefined) { rootPropertyValue = CSS.getPropertyValue(element, rootProperty); /* GET */ /* Note: The following getPropertyValue() call does not actually trigger a DOM query; getPropertyValue() will extract the hook from rootPropertyValue. */ startValue = CSS.getPropertyValue(element, property, rootPropertyValue); /* If startValue is already defined via forcefeeding, do not query the DOM for the root property's value; just grab rootProperty's zero-value template from CSS.Hooks. This overwrites the element's actual root property value (if one is set), but this is acceptable since the primary reason users forcefeed is to avoid DOM queries, and thus we likewise avoid querying the DOM for the root property's value. */ } else { /* Grab this hook's zero-value template, e.g. "0px 0px 0px black". */ rootPropertyValue = CSS.Hooks.templates[rootProperty][1]; } /* Handle non-hooked properties that haven't already been defined via forcefeeding. */ } else if (startValue === undefined) { startValue = CSS.getPropertyValue(element, property); /* GET */ } } /************************** Value Data Extraction **************************/ var separatedValue, endValueUnitType, startValueUnitType, operator = false; /* Separates a property value into its numeric value and its unit type. */ function separateValue (property, value) { var unitType, numericValue; numericValue = (value || "0") .toString() .toLowerCase() /* Match the unit type at the end of the value. */ .replace(/[%A-z]+$/, function(match) { /* Grab the unit type. */ unitType = match; /* Strip the unit type off of value. */ return ""; }); /* If no unit type was supplied, assign one that is appropriate for this property (e.g. "deg" for rotateZ or "px" for width). */ if (!unitType) { unitType = CSS.Values.getUnitType(property); } return [ numericValue, unitType ]; } /* Separate startValue. */ separatedValue = separateValue(property, startValue); startValue = separatedValue[0]; startValueUnitType = separatedValue[1]; /* Separate endValue, and extract a value operator (e.g. "+=", "-=") if one exists. */ separatedValue = separateValue(property, endValue); endValue = separatedValue[0].replace(/^([+-\/*])=/, function(match, subMatch) { operator = subMatch; /* Strip the operator off of the value. */ return ""; }); endValueUnitType = separatedValue[1]; /* Parse float values from endValue and startValue. Default to 0 if NaN is returned. */ startValue = parseFloat(startValue) || 0; endValue = parseFloat(endValue) || 0; /*************************************** Property-Specific Value Conversion ***************************************/ /* Custom support for properties that don't actually accept the % unit type, but where pollyfilling is trivial and relatively foolproof. */ if (endValueUnitType === "%") { /* A %-value fontSize/lineHeight is relative to the parent's fontSize (as opposed to the parent's dimensions), which is identical to the em unit's behavior, so we piggyback off of that. */ if (/^(fontSize|lineHeight)$/.test(property)) { /* Convert % into an em decimal value. */ endValue = endValue / 100; endValueUnitType = "em"; /* For scaleX and scaleY, convert the value into its decimal format and strip off the unit type. */ } else if (/^scale/.test(property)) { endValue = endValue / 100; endValueUnitType = ""; /* For RGB components, take the defined percentage of 255 and strip off the unit type. */ } else if (/(Red|Green|Blue)$/i.test(property)) { endValue = (endValue / 100) * 255; endValueUnitType = ""; } } /*************************** Unit Ratio Calculation ***************************/ /* When queried, the browser returns (most) CSS property values in pixels. Therefore, if an endValue with a unit type of %, em, or rem is animated toward, startValue must be converted from pixels into the same unit type as endValue in order for value manipulation logic (increment/decrement) to proceed. Further, if the startValue was forcefed or transferred from a previous call, startValue may also not be in pixels. Unit conversion logic therefore consists of two steps: 1) Calculating the ratio of %/em/rem/vh/vw relative to pixels 2) Converting startValue into the same unit of measurement as endValue based on these ratios. */ /* Unit conversion ratios are calculated by inserting a sibling node next to the target node, copying over its position property, setting values with the target unit type then comparing the returned pixel value. */ /* Note: Even if only one of these unit types is being animated, all unit ratios are calculated at once since the overhead of batching the SETs and GETs together upfront outweights the potential overhead of layout thrashing caused by re-querying for uncalculated ratios for subsequently-processed properties. */ /* Todo: Shift this logic into the calls' first tick instance so that it's synced with RAF. */ function calculateUnitRatios () { /************************ Same Ratio Checks ************************/ /* The properties below are used to determine whether the element differs sufficiently from this call's previously iterated element to also differ in its unit conversion ratios. If the properties match up with those of the prior element, the prior element's conversion ratios are used. Like most optimizations in Velocity, this is done to minimize DOM querying. */ var sameRatioIndicators = { myParent: element.parentNode || document.body, /* GET */ position: CSS.getPropertyValue(element, "position"), /* GET */ fontSize: CSS.getPropertyValue(element, "fontSize") /* GET */ }, /* Determine if the same % ratio can be used. % is based on the element's position value and its parent's width and height dimensions. */ samePercentRatio = ((sameRatioIndicators.position === callUnitConversionData.lastPosition) && (sameRatioIndicators.myParent === callUnitConversionData.lastParent)), /* Determine if the same em ratio can be used. em is relative to the element's fontSize. */ sameEmRatio = (sameRatioIndicators.fontSize === callUnitConversionData.lastFontSize); /* Store these ratio indicators call-wide for the next element to compare against. */ callUnitConversionData.lastParent = sameRatioIndicators.myParent; callUnitConversionData.lastPosition = sameRatioIndicators.position; callUnitConversionData.lastFontSize = sameRatioIndicators.fontSize; /*************************** Element-Specific Units ***************************/ /* Note: IE8 rounds to the nearest pixel when returning CSS values, thus we perform conversions using a measurement of 100 (instead of 1) to give our ratios a precision of at least 2 decimal values. */ var measurement = 100, unitRatios = {}; if (!sameEmRatio || !samePercentRatio) { var dummy = Data(element).isSVG ? document.createElementNS("http://www.w3.org/2000/svg", "rect") : document.createElement("div"); Velocity.init(dummy); sameRatioIndicators.myParent.appendChild(dummy); /* To accurately and consistently calculate conversion ratios, the element's cascaded overflow and box-sizing are stripped. Similarly, since width/height can be artificially constrained by their min-/max- equivalents, these are controlled for as well. */ /* Note: Overflow must be also be controlled for per-axis since the overflow property overwrites its per-axis values. */ $.each([ "overflow", "overflowX", "overflowY" ], function(i, property) { Velocity.CSS.setPropertyValue(dummy, property, "hidden"); }); Velocity.CSS.setPropertyValue(dummy, "position", sameRatioIndicators.position); Velocity.CSS.setPropertyValue(dummy, "fontSize", sameRatioIndicators.fontSize); Velocity.CSS.setPropertyValue(dummy, "boxSizing", "content-box"); /* width and height act as our proxy properties for measuring the horizontal and vertical % ratios. */ $.each([ "minWidth", "maxWidth", "width", "minHeight", "maxHeight", "height" ], function(i, property) { Velocity.CSS.setPropertyValue(dummy, property, measurement + "%"); }); /* paddingLeft arbitrarily acts as our proxy property for the em ratio. */ Velocity.CSS.setPropertyValue(dummy, "paddingLeft", measurement + "em"); /* Divide the returned value by the measurement to get the ratio between 1% and 1px. Default to 1 since working with 0 can produce Infinite. */ unitRatios.percentToPxWidth = callUnitConversionData.lastPercentToPxWidth = (parseFloat(CSS.getPropertyValue(dummy, "width", null, true)) || 1) / measurement; /* GET */ unitRatios.percentToPxHeight = callUnitConversionData.lastPercentToPxHeight = (parseFloat(CSS.getPropertyValue(dummy, "height", null, true)) || 1) / measurement; /* GET */ unitRatios.emToPx = callUnitConversionData.lastEmToPx = (parseFloat(CSS.getPropertyValue(dummy, "paddingLeft")) || 1) / measurement; /* GET */ sameRatioIndicators.myParent.removeChild(dummy); } else { unitRatios.emToPx = callUnitConversionData.lastEmToPx; unitRatios.percentToPxWidth = callUnitConversionData.lastPercentToPxWidth; unitRatios.percentToPxHeight = callUnitConversionData.lastPercentToPxHeight; } /*************************** Element-Agnostic Units ***************************/ /* Whereas % and em ratios are determined on a per-element basis, the rem unit only needs to be checked once per call since it's exclusively dependant upon document.body's fontSize. If this is the first time that calculateUnitRatios() is being run during this call, remToPx will still be set to its default value of null, so we calculate it now. */ if (callUnitConversionData.remToPx === null) { /* Default to browsers' default fontSize of 16px in the case of 0. */ callUnitConversionData.remToPx = parseFloat(CSS.getPropertyValue(document.body, "fontSize")) || 16; /* GET */ } /* Similarly, viewport units are %-relative to the window's inner dimensions. */ if (callUnitConversionData.vwToPx === null) { callUnitConversionData.vwToPx = parseFloat(window.innerWidth) / 100; /* GET */ callUnitConversionData.vhToPx = parseFloat(window.innerHeight) / 100; /* GET */ } unitRatios.remToPx = callUnitConversionData.remToPx; unitRatios.vwToPx = callUnitConversionData.vwToPx; unitRatios.vhToPx = callUnitConversionData.vhToPx; if (Velocity.debug >= 1) console.log("Unit ratios: " + JSON.stringify(unitRatios), element); return unitRatios; } /******************** Unit Conversion ********************/ /* The * and / operators, which are not passed in with an associated unit, inherently use startValue's unit. Skip value and unit conversion. */ if (/[\/*]/.test(operator)) { endValueUnitType = startValueUnitType; /* If startValue and endValue differ in unit type, convert startValue into the same unit type as endValue so that if endValueUnitType is a relative unit (%, em, rem), the values set during tweening will continue to be accurately relative even if the metrics they depend on are dynamically changing during the course of the animation. Conversely, if we always normalized into px and used px for setting values, the px ratio would become stale if the original unit being animated toward was relative and the underlying metrics change during the animation. */ /* Since 0 is 0 in any unit type, no conversion is necessary when startValue is 0 -- we just start at 0 with endValueUnitType. */ } else if ((startValueUnitType !== endValueUnitType) && startValue !== 0) { /* Unit conversion is also skipped when endValue is 0, but *startValueUnitType* must be used for tween values to remain accurate. */ /* Note: Skipping unit conversion here means that if endValueUnitType was originally a relative unit, the animation won't relatively match the underlying metrics if they change, but this is acceptable since we're animating toward invisibility instead of toward visibility, which remains past the point of the animation's completion. */ if (endValue === 0) { endValueUnitType = startValueUnitType; } else { /* By this point, we cannot avoid unit conversion (it's undesirable since it causes layout thrashing). If we haven't already, we trigger calculateUnitRatios(), which runs once per element per call. */ elementUnitConversionData = elementUnitConversionData || calculateUnitRatios(); /* The following RegEx matches CSS properties that have their % values measured relative to the x-axis. */ /* Note: W3C spec mandates that all of margin and padding's properties (even top and bottom) are %-relative to the *width* of the parent element. */ var axis = (/margin|padding|left|right|width|text|word|letter/i.test(property) || /X$/.test(property) || property === "x") ? "x" : "y"; /* In order to avoid generating n^2 bespoke conversion functions, unit conversion is a two-step process: 1) Convert startValue into pixels. 2) Convert this new pixel value into endValue's unit type. */ switch (startValueUnitType) { case "%": /* Note: translateX and translateY are the only properties that are %-relative to an element's own dimensions -- not its parent's dimensions. Velocity does not include a special conversion process to account for this behavior. Therefore, animating translateX/Y from a % value to a non-% value will produce an incorrect start value. Fortunately, this sort of cross-unit conversion is rarely done by users in practice. */ startValue *= (axis === "x" ? elementUnitConversionData.percentToPxWidth : elementUnitConversionData.percentToPxHeight); break; case "px": /* px acts as our midpoint in the unit conversion process; do nothing. */ break; default: startValue *= elementUnitConversionData[startValueUnitType + "ToPx"]; } /* Invert the px ratios to convert into to the target unit. */ switch (endValueUnitType) { case "%": startValue *= 1 / (axis === "x" ? elementUnitConversionData.percentToPxWidth : elementUnitConversionData.percentToPxHeight); break; case "px": /* startValue is already in px, do nothing; we're done. */ break; default: startValue *= 1 / elementUnitConversionData[endValueUnitType + "ToPx"]; } } } /********************* Relative Values *********************/ /* Operator logic must be performed last since it requires unit-normalized start and end values. */ /* Note: Relative *percent values* do not behave how most people think; while one would expect "+=50%" to increase the property 1.5x its current value, it in fact increases the percent units in absolute terms: 50 points is added on top of the current % value. */ switch (operator) { case "+": endValue = startValue + endValue; break; case "-": endValue = startValue - endValue; break; case "*": endValue = startValue * endValue; break; case "/": endValue = startValue / endValue; break; } /************************** tweensContainer Push **************************/ /* Construct the per-property tween object, and push it to the element's tweensContainer. */ tweensContainer[property] = { rootPropertyValue: rootPropertyValue, startValue: startValue, currentValue: startValue, endValue: endValue, unitType: endValueUnitType, easing: easing }; if (Velocity.debug) console.log("tweensContainer (" + property + "): " + JSON.stringify(tweensContainer[property]), element); } /* Along with its property data, store a reference to the element itself onto tweensContainer. */ tweensContainer.element = element; } /***************** Call Push *****************/ /* Note: tweensContainer can be empty if all of the properties in this call's property map were skipped due to not being supported by the browser. The element property is used for checking that the tweensContainer has been appended to. */ if (tweensContainer.element) { /* Apply the "velocity-animating" indicator class. */ CSS.Values.addClass(element, "velocity-animating"); /* The call array houses the tweensContainers for each element being animated in the current call. */ call.push(tweensContainer); /* Store the tweensContainer and options if we're working on the default effects queue, so that they can be used by the reverse command. */ if (opts.queue === "") { Data(element).tweensContainer = tweensContainer; Data(element).opts = opts; } /* Switch on the element's animating flag. */ Data(element).isAnimating = true; /* Once the final element in this call's element set has been processed, push the call array onto Velocity.State.calls for the animation tick to immediately begin processing. */ if (elementsIndex === elementsLength - 1) { /* Add the current call plus its associated metadata (the element set and the call's options) onto the global call container. Anything on this call container is subjected to tick() processing. */ Velocity.State.calls.push([ call, elements, opts, null, promiseData.resolver ]); /* If the animation tick isn't running, start it. (Velocity shuts it off when there are no active calls to process.) */ if (Velocity.State.isTicking === false) { Velocity.State.isTicking = true; /* Start the tick loop. */ tick(); } } else { elementsIndex++; } } } /* When the queue option is set to false, the call skips the element's queue and fires immediately. */ if (opts.queue === false) { /* Since this buildQueue call doesn't respect the element's existing queue (which is where a delay option would have been appended), we manually inject the delay property here with an explicit setTimeout. */ if (opts.delay) { setTimeout(buildQueue, opts.delay); } else { buildQueue(); } /* Otherwise, the call undergoes element queueing as normal. */ /* Note: To interoperate with jQuery, Velocity uses jQuery's own $.queue() stack for queuing logic. */ } else { $.queue(element, opts.queue, function(next, clearQueue) { /* If the clearQueue flag was passed in by the stop command, resolve this call's promise. (Promises can only be resolved once, so it's fine if this is repeatedly triggered for each element in the associated call.) */ if (clearQueue === true) { if (promiseData.promise) { promiseData.resolver(elements); } /* Do not continue with animation queueing. */ return true; } /* This flag indicates to the upcoming completeCall() function that this queue entry was initiated by Velocity. See completeCall() for further details. */ Velocity.velocityQueueEntryFlag = true; buildQueue(next); }); } /********************* Auto-Dequeuing *********************/ /* As per jQuery's $.queue() behavior, to fire the first non-custom-queue entry on an element, the element must be dequeued if its queue stack consists *solely* of the current call. (This can be determined by checking for the "inprogress" item that jQuery prepends to active queue stack arrays.) Regardless, whenever the element's queue is further appended with additional items -- including $.delay()'s or even $.animate() calls, the queue's first entry is automatically fired. This behavior contrasts that of custom queues, which never auto-fire. */ /* Note: When an element set is being subjected to a non-parallel Velocity call, the animation will not begin until each one of the elements in the set has reached the end of its individually pre-existing queue chain. */ /* Note: Unfortunately, most people don't fully grasp jQuery's powerful, yet quirky, $.queue() function. Lean more here: http://stackoverflow.com/questions/1058158/can-somebody-explain-jquery-queue-to-me */ if ((opts.queue === "" || opts.queue === "fx") && $.queue(element)[0] !== "inprogress") { $.dequeue(element); } } /************************** Element Set Iteration **************************/ /* If the "nodeType" property exists on the elements variable, we're animating a single element. Place it in an array so that $.each() can iterate over it. */ $.each(elements, function(i, element) { /* Ensure each element in a set has a nodeType (is a real element) to avoid throwing errors. */ if (Type.isNode(element)) { processElement.call(element); } }); /****************** Option: Loop ******************/ /* The loop option accepts an integer indicating how many times the element should loop between the values in the current call's properties map and the element's property values prior to this call. */ /* Note: The loop option's logic is performed here -- after element processing -- because the current call needs to undergo its queue insertion prior to the loop option generating its series of constituent "reverse" calls, which chain after the current call. Two reverse calls (two "alternations") constitute one loop. */ var opts = $.extend({}, Velocity.defaults, options), reverseCallsCount; opts.loop = parseInt(opts.loop); reverseCallsCount = (opts.loop * 2) - 1; if (opts.loop) { /* Double the loop count to convert it into its appropriate number of "reverse" calls. Subtract 1 from the resulting value since the current call is included in the total alternation count. */ for (var x = 0; x < reverseCallsCount; x++) { /* Since the logic for the reverse action occurs inside Queueing and therefore this call's options object isn't parsed until then as well, the current call's delay option must be explicitly passed into the reverse call so that the delay logic that occurs inside *Pre-Queueing* can process it. */ var reverseOptions = { delay: opts.delay, progress: opts.progress }; /* If a complete callback was passed into this call, transfer it to the loop redirect's final "reverse" call so that it's triggered when the entire redirect is complete (and not when the very first animation is complete). */ if (x === reverseCallsCount - 1) { reverseOptions.display = opts.display; reverseOptions.visibility = opts.visibility; reverseOptions.complete = opts.complete; } animate(elements, "reverse", reverseOptions); } } /*************** Chaining ***************/ /* Return the elements back to the call chain, with wrapped elements taking precedence in case Velocity was called via the $.fn. extension. */ return getChain(); }; /* Turn Velocity into the animation function, extended with the pre-existing Velocity object. */ Velocity = $.extend(animate, Velocity); /* For legacy support, also expose the literal animate method. */ Velocity.animate = animate; /************** Timing **************/ /* Ticker function. */ var ticker = window.requestAnimationFrame || rAFShim; /* Inactive browser tabs pause rAF, which results in all active animations immediately sprinting to their completion states when the tab refocuses. To get around this, we dynamically switch rAF to setTimeout (which the browser *doesn't* pause) when the tab loses focus. We skip this for mobile devices to avoid wasting battery power on inactive tabs. */ /* Note: Tab focus detection doesn't work on older versions of IE, but that's okay since they don't support rAF to begin with. */ if (!Velocity.State.isMobile && document.hidden !== undefined) { document.addEventListener("visibilitychange", function() { /* Reassign the rAF function (which the global tick() function uses) based on the tab's focus state. */ if (document.hidden) { ticker = function(callback) { /* The tick function needs a truthy first argument in order to pass its internal timestamp check. */ return setTimeout(function() { callback(true) }, 16); }; /* The rAF loop has been paused by the browser, so we manually restart the tick. */ tick(); } else { ticker = window.requestAnimationFrame || rAFShim; } }); } /************ Tick ************/ /* Note: All calls to Velocity are pushed to the Velocity.State.calls array, which is fully iterated through upon each tick. */ function tick (timestamp) { /* An empty timestamp argument indicates that this is the first tick occurence since ticking was turned on. We leverage this metadata to fully ignore the first tick pass since RAF's initial pass is fired whenever the browser's next tick sync time occurs, which results in the first elements subjected to Velocity calls being animated out of sync with any elements animated immediately thereafter. In short, we ignore the first RAF tick pass so that elements being immediately consecutively animated -- instead of simultaneously animated by the same Velocity call -- are properly batched into the same initial RAF tick and consequently remain in sync thereafter. */ if (timestamp) { /* We ignore RAF's high resolution timestamp since it can be significantly offset when the browser is under high stress; we opt for choppiness over allowing the browser to drop huge chunks of frames. */ var timeCurrent = (new Date).getTime(); /******************** Call Iteration ********************/ var callsLength = Velocity.State.calls.length; /* To speed up iterating over this array, it is compacted (falsey items -- calls that have completed -- are removed) when its length has ballooned to a point that can impact tick performance. This only becomes necessary when animation has been continuous with many elements over a long period of time; whenever all active calls are completed, completeCall() clears Velocity.State.calls. */ if (callsLength > 10000) { Velocity.State.calls = compactSparseArray(Velocity.State.calls); } /* Iterate through each active call. */ for (var i = 0; i < callsLength; i++) { /* When a Velocity call is completed, its Velocity.State.calls entry is set to false. Continue on to the next call. */ if (!Velocity.State.calls[i]) { continue; } /************************ Call-Wide Variables ************************/ var callContainer = Velocity.State.calls[i], call = callContainer[0], opts = callContainer[2], timeStart = callContainer[3], firstTick = !!timeStart, tweenDummyValue = null; /* If timeStart is undefined, then this is the first time that this call has been processed by tick(). We assign timeStart now so that its value is as close to the real animation start time as possible. (Conversely, had timeStart been defined when this call was added to Velocity.State.calls, the delay between that time and now would cause the first few frames of the tween to be skipped since percentComplete is calculated relative to timeStart.) */ /* Further, subtract 16ms (the approximate resolution of RAF) from the current time value so that the first tick iteration isn't wasted by animating at 0% tween completion, which would produce the same style value as the element's current value. */ if (!timeStart) { timeStart = Velocity.State.calls[i][3] = timeCurrent - 16; } /* The tween's completion percentage is relative to the tween's start time, not the tween's start value (which would result in unpredictable tween durations since JavaScript's timers are not particularly accurate). Accordingly, we ensure that percentComplete does not exceed 1. */ var percentComplete = Math.min((timeCurrent - timeStart) / opts.duration, 1); /********************** Element Iteration **********************/ /* For every call, iterate through each of the elements in its set. */ for (var j = 0, callLength = call.length; j < callLength; j++) { var tweensContainer = call[j], element = tweensContainer.element; /* Check to see if this element has been deleted midway through the animation by checking for the continued existence of its data cache. If it's gone, skip animating this element. */ if (!Data(element)) { continue; } var transformPropertyExists = false; /********************************** Display & Visibility Toggling **********************************/ /* If the display option is set to non-"none", set it upfront so that the element can become visible before tweening begins. (Otherwise, display's "none" value is set in completeCall() once the animation has completed.) */ if (opts.display !== undefined && opts.display !== null && opts.display !== "none") { if (opts.display === "flex") { var flexValues = [ "-webkit-box", "-moz-box", "-ms-flexbox", "-webkit-flex" ]; $.each(flexValues, function(i, flexValue) { CSS.setPropertyValue(element, "display", flexValue); }); } CSS.setPropertyValue(element, "display", opts.display); } /* Same goes with the visibility option, but its "none" equivalent is "hidden". */ if (opts.visibility !== undefined && opts.visibility !== "hidden") { CSS.setPropertyValue(element, "visibility", opts.visibility); } /************************ Property Iteration ************************/ /* For every element, iterate through each property. */ for (var property in tweensContainer) { /* Note: In addition to property tween data, tweensContainer contains a reference to its associated element. */ if (property !== "element") { var tween = tweensContainer[property], currentValue, /* Easing can either be a pre-genereated function or a string that references a pre-registered easing on the Velocity.Easings object. In either case, return the appropriate easing *function*. */ easing = Type.isString(tween.easing) ? Velocity.Easings[tween.easing] : tween.easing; /****************************** Current Value Calculation ******************************/ /* If this is the last tick pass (if we've reached 100% completion for this tween), ensure that currentValue is explicitly set to its target endValue so that it's not subjected to any rounding. */ if (percentComplete === 1) { currentValue = tween.endValue; /* Otherwise, calculate currentValue based on the current delta from startValue. */ } else { var tweenDelta = tween.endValue - tween.startValue; currentValue = tween.startValue + (tweenDelta * easing(percentComplete, opts, tweenDelta)); /* If no value change is occurring, don't proceed with DOM updating. */ if (!firstTick && (currentValue === tween.currentValue)) { continue; } } tween.currentValue = currentValue; /* If we're tweening a fake 'tween' property in order to log transition values, update the one-per-call variable so that it can be passed into the progress callback. */ if (property === "tween") { tweenDummyValue = currentValue; } else { /****************** Hooks: Part I ******************/ /* For hooked properties, the newly-updated rootPropertyValueCache is cached onto the element so that it can be used for subsequent hooks in this call that are associated with the same root property. If we didn't cache the updated rootPropertyValue, each subsequent update to the root property in this tick pass would reset the previous hook's updates to rootPropertyValue prior to injection. A nice performance byproduct of rootPropertyValue caching is that subsequently chained animations using the same hookRoot but a different hook can use this cached rootPropertyValue. */ if (CSS.Hooks.registered[property]) { var hookRoot = CSS.Hooks.getRoot(property), rootPropertyValueCache = Data(element).rootPropertyValueCache[hookRoot]; if (rootPropertyValueCache) { tween.rootPropertyValue = rootPropertyValueCache; } } /***************** DOM Update *****************/ /* setPropertyValue() returns an array of the property name and property value post any normalization that may have been performed. */ /* Note: To solve an IE<=8 positioning bug, the unit type is dropped when setting a property value of 0. */ var adjustedSetData = CSS.setPropertyValue(element, /* SET */ property, tween.currentValue + (parseFloat(currentValue) === 0 ? "" : tween.unitType), tween.rootPropertyValue, tween.scrollData); /******************* Hooks: Part II *******************/ /* Now that we have the hook's updated rootPropertyValue (the post-processed value provided by adjustedSetData), cache it onto the element. */ if (CSS.Hooks.registered[property]) { /* Since adjustedSetData contains normalized data ready for DOM updating, the rootPropertyValue needs to be re-extracted from its normalized form. ?? */ if (CSS.Normalizations.registered[hookRoot]) { Data(element).rootPropertyValueCache[hookRoot] = CSS.Normalizations.registered[hookRoot]("extract", null, adjustedSetData[1]); } else { Data(element).rootPropertyValueCache[hookRoot] = adjustedSetData[1]; } } /*************** Transforms ***************/ /* Flag whether a transform property is being animated so that flushTransformCache() can be triggered once this tick pass is complete. */ if (adjustedSetData[0] === "transform") { transformPropertyExists = true; } } } } /**************** mobileHA ****************/ /* If mobileHA is enabled, set the translate3d transform to null to force hardware acceleration. It's safe to override this property since Velocity doesn't actually support its animation (hooks are used in its place). */ if (opts.mobileHA) { /* Don't set the null transform hack if we've already done so. */ if (Data(element).transformCache.translate3d === undefined) { /* All entries on the transformCache object are later concatenated into a single transform string via flushTransformCache(). */ Data(element).transformCache.translate3d = "(0px, 0px, 0px)"; transformPropertyExists = true; } } if (transformPropertyExists) { CSS.flushTransformCache(element); } } /* The non-"none" display value is only applied to an element once -- when its associated call is first ticked through. Accordingly, it's set to false so that it isn't re-processed by this call in the next tick. */ if (opts.display !== undefined && opts.display !== "none") { Velocity.State.calls[i][2].display = false; } if (opts.visibility !== undefined && opts.visibility !== "hidden") { Velocity.State.calls[i][2].visibility = false; } /* Pass the elements and the timing data (percentComplete, msRemaining, timeStart, tweenDummyValue) into the progress callback. */ if (opts.progress) { opts.progress.call(callContainer[1], callContainer[1], percentComplete, Math.max(0, (timeStart + opts.duration) - timeCurrent), timeStart, tweenDummyValue); } /* If this call has finished tweening, pass its index to completeCall() to handle call cleanup. */ if (percentComplete === 1) { completeCall(i); } } } /* Note: completeCall() sets the isTicking flag to false when the last call on Velocity.State.calls has completed. */ if (Velocity.State.isTicking) { ticker(tick); } } /********************** Call Completion **********************/ /* Note: Unlike tick(), which processes all active calls at once, call completion is handled on a per-call basis. */ function completeCall (callIndex, isStopped) { /* Ensure the call exists. */ if (!Velocity.State.calls[callIndex]) { return false; } /* Pull the metadata from the call. */ var call = Velocity.State.calls[callIndex][0], elements = Velocity.State.calls[callIndex][1], opts = Velocity.State.calls[callIndex][2], resolver = Velocity.State.calls[callIndex][4]; var remainingCallsExist = false; /************************* Element Finalization *************************/ for (var i = 0, callLength = call.length; i < callLength; i++) { var element = call[i].element; /* If the user set display to "none" (intending to hide the element), set it now that the animation has completed. */ /* Note: display:none isn't set when calls are manually stopped (via Velocity("stop"). */ /* Note: Display gets ignored with "reverse" calls and infinite loops, since this behavior would be undesirable. */ if (!isStopped && !opts.loop) { if (opts.display === "none") { CSS.setPropertyValue(element, "display", opts.display); } if (opts.visibility === "hidden") { CSS.setPropertyValue(element, "visibility", opts.visibility); } } /* If the element's queue is empty (if only the "inprogress" item is left at position 0) or if its queue is about to run a non-Velocity-initiated entry, turn off the isAnimating flag. A non-Velocity-initiatied queue entry's logic might alter an element's CSS values and thereby cause Velocity's cached value data to go stale. To detect if a queue entry was initiated by Velocity, we check for the existence of our special Velocity.queueEntryFlag declaration, which minifiers won't rename since the flag is assigned to jQuery's global $ object and thus exists out of Velocity's own scope. */ if (opts.loop !== true && ($.queue(element)[1] === undefined || !/\.velocityQueueEntryFlag/i.test($.queue(element)[1]))) { /* The element may have been deleted. Ensure that its data cache still exists before acting on it. */ if (Data(element)) { Data(element).isAnimating = false; /* Clear the element's rootPropertyValueCache, which will become stale. */ Data(element).rootPropertyValueCache = {}; var transformHAPropertyExists = false; /* If any 3D transform subproperty is at its default value (regardless of unit type), remove it. */ $.each(CSS.Lists.transforms3D, function(i, transformName) { var defaultValue = /^scale/.test(transformName) ? 1 : 0, currentValue = Data(element).transformCache[transformName]; if (Data(element).transformCache[transformName] !== undefined && new RegExp("^\\(" + defaultValue + "[^.]").test(currentValue)) { transformHAPropertyExists = true; delete Data(element).transformCache[transformName]; } }); /* Mobile devices have hardware acceleration removed at the end of the animation in order to avoid hogging the GPU's memory. */ if (opts.mobileHA) { transformHAPropertyExists = true; delete Data(element).transformCache.translate3d; } /* Flush the subproperty removals to the DOM. */ if (transformHAPropertyExists) { CSS.flushTransformCache(element); } /* Remove the "velocity-animating" indicator class. */ CSS.Values.removeClass(element, "velocity-animating"); } } /********************* Option: Complete *********************/ /* Complete is fired once per call (not once per element) and is passed the full raw DOM element set as both its context and its first argument. */ /* Note: Callbacks aren't fired when calls are manually stopped (via Velocity("stop"). */ if (!isStopped && opts.complete && !opts.loop && (i === callLength - 1)) { /* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */ try { opts.complete.call(elements, elements); } catch (error) { setTimeout(function() { throw error; }, 1); } } /********************** Promise Resolving **********************/ /* Note: Infinite loops don't return promises. */ if (resolver && opts.loop !== true) { resolver(elements); } /**************************** Option: Loop (Infinite) ****************************/ if (Data(element) && opts.loop === true && !isStopped) { /* If a rotateX/Y/Z property is being animated to 360 deg with loop:true, swap tween start/end values to enable continuous iterative rotation looping. (Otherise, the element would just rotate back and forth.) */ $.each(Data(element).tweensContainer, function(propertyName, tweenContainer) { if (/^rotate/.test(propertyName) && parseFloat(tweenContainer.endValue) === 360) { tweenContainer.endValue = 0; tweenContainer.startValue = 360; } if (/^backgroundPosition/.test(propertyName) && parseFloat(tweenContainer.endValue) === 100 && tweenContainer.unitType === "%") { tweenContainer.endValue = 0; tweenContainer.startValue = 100; } }); Velocity(element, "reverse", { loop: true, delay: opts.delay }); } /*************** Dequeueing ***************/ /* Fire the next call in the queue so long as this call's queue wasn't set to false (to trigger a parallel animation), which would have already caused the next call to fire. Note: Even if the end of the animation queue has been reached, $.dequeue() must still be called in order to completely clear jQuery's animation queue. */ if (opts.queue !== false) { $.dequeue(element, opts.queue); } } /************************ Calls Array Cleanup ************************/ /* Since this call is complete, set it to false so that the rAF tick skips it. This array is later compacted via compactSparseArray(). (For performance reasons, the call is set to false instead of being deleted from the array: http://www.html5rocks.com/en/tutorials/speed/v8/) */ Velocity.State.calls[callIndex] = false; /* Iterate through the calls array to determine if this was the final in-progress animation. If so, set a flag to end ticking and clear the calls array. */ for (var j = 0, callsLength = Velocity.State.calls.length; j < callsLength; j++) { if (Velocity.State.calls[j] !== false) { remainingCallsExist = true; break; } } if (remainingCallsExist === false) { /* tick() will detect this flag upon its next iteration and subsequently turn itself off. */ Velocity.State.isTicking = false; /* Clear the calls array so that its length is reset. */ delete Velocity.State.calls; Velocity.State.calls = []; } } /****************** Frameworks ******************/ /* Both jQuery and Zepto allow their $.fn object to be extended to allow wrapped elements to be subjected to plugin calls. If either framework is loaded, register a "velocity" extension pointing to Velocity's core animate() method. Velocity also registers itself onto a global container (window.jQuery || window.Zepto || window) so that certain features are accessible beyond just a per-element scope. This master object contains an .animate() method, which is later assigned to $.fn (if jQuery or Zepto are present). Accordingly, Velocity can both act on wrapped DOM elements and stand alone for targeting raw DOM elements. */ global.Velocity = Velocity; if (global !== window) { /* Assign the element function to Velocity's core animate() method. */ global.fn.velocity = animate; /* Assign the object function's defaults to Velocity's global defaults object. */ global.fn.velocity.defaults = Velocity.defaults; } /*********************** Packaged Redirects ***********************/ /* slideUp, slideDown */ $.each([ "Down", "Up" ], function(i, direction) { Velocity.Redirects["slide" + direction] = function (element, options, elementsIndex, elementsSize, elements, promiseData) { var opts = $.extend({}, options), begin = opts.begin, complete = opts.complete, computedValues = { height: "", marginTop: "", marginBottom: "", paddingTop: "", paddingBottom: "" }, inlineValues = {}; if (opts.display === undefined) { /* Show the element before slideDown begins and hide the element after slideUp completes. */ /* Note: Inline elements cannot have dimensions animated, so they're reverted to inline-block. */ opts.display = (direction === "Down" ? (Velocity.CSS.Values.getDisplayType(element) === "inline" ? "inline-block" : "block") : "none"); } opts.begin = function() { /* If the user passed in a begin callback, fire it now. */ begin && begin.call(elements, elements); /* Cache the elements' original vertical dimensional property values so that we can animate back to them. */ for (var property in computedValues) { inlineValues[property] = element.style[property]; /* For slideDown, use forcefeeding to animate all vertical properties from 0. For slideUp, use forcefeeding to start from computed values and animate down to 0. */ var propertyValue = Velocity.CSS.getPropertyValue(element, property); computedValues[property] = (direction === "Down") ? [ propertyValue, 0 ] : [ 0, propertyValue ]; } /* Force vertical overflow content to clip so that sliding works as expected. */ inlineValues.overflow = element.style.overflow; element.style.overflow = "hidden"; } opts.complete = function() { /* Reset element to its pre-slide inline values once its slide animation is complete. */ for (var property in inlineValues) { element.style[property] = inlineValues[property]; } /* If the user passed in a complete callback, fire it now. */ complete && complete.call(elements, elements); promiseData && promiseData.resolver(elements); }; Velocity(element, computedValues, opts); }; }); /* fadeIn, fadeOut */ $.each([ "In", "Out" ], function(i, direction) { Velocity.Redirects["fade" + direction] = function (element, options, elementsIndex, elementsSize, elements, promiseData) { var opts = $.extend({}, options), propertiesMap = { opacity: (direction === "In") ? 1 : 0 }, originalComplete = opts.complete; /* Since redirects are triggered individually for each element in the animated set, avoid repeatedly triggering callbacks by firing them only when the final element has been reached. */ if (elementsIndex !== elementsSize - 1) { opts.complete = opts.begin = null; } else { opts.complete = function() { if (originalComplete) { originalComplete.call(elements, elements); } promiseData && promiseData.resolver(elements); } } /* If a display was passed in, use it. Otherwise, default to "none" for fadeOut or the element-specific default for fadeIn. */ /* Note: We allow users to pass in "null" to skip display setting altogether. */ if (opts.display === undefined) { opts.display = (direction === "In" ? "auto" : "none"); } Velocity(this, propertiesMap, opts); }; }); return Velocity; }((window.jQuery || window.Zepto || window), window, document); })); /****************** Known Issues ******************/ /* The CSS spec mandates that the translateX/Y/Z transforms are %-relative to the element itself -- not its parent. Velocity, however, doesn't make this distinction. Thus, converting to or from the % unit with these subproperties will produce an inaccurate conversion value. The same issue exists with the cx/cy attributes of SVG circles and ellipses. */ /***/ }, /* 285 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcNotification = __webpack_require__(286); var _rcNotification2 = _interopRequireDefault(_rcNotification); var defaultDuration = 1.5; var top = undefined; var messageInstance = undefined; var key = 1; function getMessageInstance() { messageInstance = messageInstance || _rcNotification2['default'].newInstance({ prefixCls: 'ant-message', transitionName: 'move-up', style: { top: top } // 覆盖原来的样式 }); return messageInstance; } function notice(content, duration, type, onClose) { if (duration === undefined) duration = defaultDuration; var iconClass = ({ 'info': 'anticon-info-circle ant-message-info', 'success': 'anticon-check-circle ant-message-success', 'error': 'anticon-exclamation-circle ant-message-error', 'loading': 'anticon-loading ant-message-loading' })[type]; var instance = getMessageInstance(); instance.notice({ key: key, duration: duration, style: {}, content: _react2['default'].createElement( 'div', { className: 'ant-message-custom-content' }, _react2['default'].createElement('i', { className: 'anticon ' + iconClass }), _react2['default'].createElement( 'span', null, content ) ), onClose: onClose }); return (function () { var target = key++; return function () { instance.removeNotice(target); }; })(); } exports['default'] = { info: function info(content, duration, onClose) { return notice(content, duration, 'info', onClose); }, success: function success(content, duration, onClose) { return notice(content, duration, 'success', onClose); }, error: function error(content, duration, onClose) { return notice(content, duration, 'error', onClose); }, loading: function loading(content, duration, onClose) { return notice(content, duration, 'loading', onClose); }, config: function config(options) { if (options.top) { top = options.top; } } }; module.exports = exports['default']; /***/ }, /* 286 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(287); /***/ }, /* 287 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var _rcUtil = __webpack_require__(77); var Notice = _react2['default'].createClass({ displayName: 'Notice', getDefaultProps: function getDefaultProps() { return { onEnd: function onEnd() {}, duration: 1.5, style: { right: '50%' } }; }, clearCloseTimer: function clearCloseTimer() { if (this.closeTimer) { clearTimeout(this.closeTimer); this.closeTimer = null; } }, componentDidUpdate: function componentDidUpdate() { this.componentDidMount(); }, componentDidMount: function componentDidMount() { var _this = this; this.clearCloseTimer(); if (this.props.duration) { this.closeTimer = setTimeout(function () { _this.close(); }, this.props.duration * 1000); } }, componentWillUnmount: function componentWillUnmount() { this.clearCloseTimer(); }, close: function close() { this.clearCloseTimer(); this.props.onClose(); }, render: function render() { var _className; var props = this.props; var componentClass = props.prefixCls + '-notice'; var className = (_className = {}, _defineProperty(_className, '' + componentClass, 1), _defineProperty(_className, componentClass + '-closable', props.closable), _defineProperty(_className, props.className, !!props.className), _className); return _react2['default'].createElement( 'div', { className: (0, _rcUtil.classSet)(className), style: props.style }, _react2['default'].createElement( 'div', { className: componentClass + '-content' }, this.props.children ), props.closable ? _react2['default'].createElement( 'a', { tabIndex: "0", onClick: this.close, className: componentClass + '-close' }, _react2['default'].createElement('span', { className: componentClass + '-close-x' }) ) : null ); } }); var seed = 0; var now = Date.now(); function getUuid() { return 'rcNotification_' + now + '_' + seed++; } var Notification = _react2['default'].createClass({ displayName: 'Notification', getInitialState: function getInitialState() { return { notices: [] }; }, getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-notification', animation: 'fade', style: { 'top': 65, left: '50%' } }; }, remove: function remove(key) { var notices = this.state.notices.filter(function (notice) { return notice.key !== key; }); this.setState({ notices: notices }); }, add: function add(notice) { var key = notice.key = notice.key || getUuid(); var notices = this.state.notices; if (!notices.filter(function (v) { return v.key === key; }).length) { this.setState({ notices: notices.concat(notice) }); } }, getTransitionName: function getTransitionName() { var props = this.props; var transitionName = props.transitionName; if (!transitionName && props.animation) { transitionName = props.prefixCls + '-' + props.animation; } return transitionName; }, render: function render() { var _className2, _this2 = this; var props = this.props; var noticeNodes = this.state.notices.map(function (notice) { var onClose = (0, _rcUtil.createChainedFunction)(_this2.remove.bind(_this2, notice.key), notice.onClose); return _react2['default'].createElement( Notice, _extends({ prefixCls: props.prefixCls }, notice, { onClose: onClose }), notice.content ); }); var className = (_className2 = {}, _defineProperty(_className2, props.prefixCls, 1), _defineProperty(_className2, props.className, !!props.className), _className2); return _react2['default'].createElement( 'div', { className: (0, _rcUtil.classSet)(className), style: props.style }, _react2['default'].createElement( _rcAnimate2['default'], { transitionName: this.getTransitionName() }, noticeNodes ) ); } }); Notification.newInstance = function (props) { props = props || {}; var div = document.createElement('div'); document.body.appendChild(div); var notification = _react2['default'].render(_react2['default'].createElement(Notification, props), div); return { notice: function notice(noticeProps) { notification.add(noticeProps); }, removeNotice: function removeNotice(key) { notification.remove(key); }, component: notification, destroy: function destroy() { _react2['default'].unmountComponentAtNode(div); document.body.removeChild(div); } }; }; module.exports = Notification; /***/ }, /* 288 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcSlider = __webpack_require__(289); var _rcSlider2 = _interopRequireDefault(_rcSlider); exports['default'] = _react2['default'].createClass({ displayName: 'index', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-slider', tipTransitionName: 'zoom-down' }; }, render: function render() { return _react2['default'].createElement(_rcSlider2['default'], this.props); } }); module.exports = exports['default']; /***/ }, /* 289 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(290); /***/ }, /* 290 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcTooltip = __webpack_require__(137); var _rcTooltip2 = _interopRequireDefault(_rcTooltip); var _rcUtil = __webpack_require__(77); var _rcUtil2 = _interopRequireDefault(_rcUtil); function noop() {} function pauseEvent(e) { e.cancelBubble = true; e.returnValue = false; if (e.stopPropagation) { e.stopPropagation(); } if (e.preventDefault) { e.preventDefault(); } } function prefixClsFn(prefixCls) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } return args.map(function (s) { return prefixCls + '-' + s; }).join(' '); } function getValueFromIndex(props) { var value = undefined; var marksLen = props.marks.length; var index = undefined; if ('index' in props) { index = props.index; } else { index = props.defaultIndex; } if (marksLen > 0) { value = (props.max - props.min) / (marksLen - 1) * index; value = value.toFixed(5) / 1; } return value; } var Slider = _react2['default'].createClass({ displayName: 'Slider', propTypes: { min: _react2['default'].PropTypes.number, max: _react2['default'].PropTypes.number, step: _react2['default'].PropTypes.number, defaultValue: _react2['default'].PropTypes.number, defaultIndex: _react2['default'].PropTypes.number, value: _react2['default'].PropTypes.number, index: _react2['default'].PropTypes.number, marks: _react2['default'].PropTypes.array, isIncluded: _react2['default'].PropTypes.bool, className: _react2['default'].PropTypes.string, prefixCls: _react2['default'].PropTypes.string, disabled: _react2['default'].PropTypes.bool, children: _react2['default'].PropTypes.any, onBeforeChange: _react2['default'].PropTypes.func, onChange: _react2['default'].PropTypes.func, onAfterChange: _react2['default'].PropTypes.func, tipTransitionName: _react2['default'].PropTypes.string }, getDefaultProps: function getDefaultProps() { return { min: 0, max: 100, step: 1, defaultValue: 0, marks: [], isIncluded: true, className: '', prefixCls: 'rc-slider', disabled: false, defaultIndex: 0, tipTransitionName: '' }; }, getInitialState: function getInitialState() { var props = this.props; var value = props.defaultValue; if ('value' in props) { value = props.value; } value = this._trimAlignValue(value); var marksLen = props.marks.length; if (marksLen > 0) { value = getValueFromIndex(props); } return { dragging: false, showTooltip: false, value: value }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('value' in nextProps) { this.setState({ value: nextProps.value }); } else if ('index' in nextProps) { this.setState({ value: getValueFromIndex(nextProps) }); } }, onMouseUp: function onMouseUp(e) { var m = e.target; var handleDom = _react2['default'].findDOMNode(this.refs.handle); var showToolTip = false; if (m === handleDom) { showToolTip = true; } this._end('mouse', showToolTip); }, onTouchUp: function onTouchUp() { this._end('touch'); }, onMouseMove: function onMouseMove(e) { var position = e.pageX || e.clientX + document.documentElement.scrollLeft; // to compat ie8 this.onMove(e, position); }, onTouchMove: function onTouchMove(e) { if (e.touches.length > 1 || e.type === 'touchend' && e.touches.length > 0) { this._end('touch'); return; } var position = this._getTouchPosition(e); this.onMove(e, position); }, onMove: function onMove(e, position) { pauseEvent(e); var props = this.props; var state = this.state; var value = state.value; var oldValue = value; var diffPosition = position - this.startPosition; var diffValue = diffPosition / this.getSliderLength() * (props.max - props.min); value = this._trimAlignValue(this.startValue + diffValue); if (value !== oldValue && !('value' in props) && !('index' in props)) { this.setState({ value: value }); } if (value !== oldValue) { this._triggerEvents('onChange', value); } }, onTouchStart: function onTouchStart(e) { if (e.touches.length > 1 || e.type.toLowerCase() === 'touchend' && e.touches.length > 0) { return; } var position = this._getTouchPosition(e); var value = this._calValueByPos(position); this._triggerEvents('onChange', value); this._start(position, value); this._addDocumentEvents('touch'); pauseEvent(e); }, onSliderMouseDown: function onSliderMouseDown(e) { var position = e.pageX || e.clientX + document.documentElement.scrollLeft; // to compat ie8 var value = this._calValueByPos(position); this._triggerEvents('onChange', value); this._start(position, value); this._addDocumentEvents('mouse'); pauseEvent(e); }, getIndex: function getIndex(v) { var props = this.props; var value = v === undefined ? this.state.value : v; if (props.marks.length === 0) { return Math.floor((value - props.min) / props.step); } var unit = ((props.max - props.min) / (props.marks.length - 1)).toFixed(5); return Math.round(value / unit); }, getSliderLength: function getSliderLength() { var slider = this.refs.slider; if (!slider) { return 0; } return slider.getDOMNode().clientWidth; }, getSliderStart: function getSliderStart() { var slider = this.refs.slider.getDOMNode(); var rect = slider.getBoundingClientRect(); return rect.left; }, renderSteps: function renderSteps() { var props = this.props; var marksLen = props.marks.length; var stepNum = marksLen > 0 ? marksLen : Math.floor((props.max - props.min) / props.step) + 1; var unit = 100 / (stepNum - 1); var prefixCls = props.prefixCls; var stepClassName = prefixClsFn(prefixCls, 'step'); var elements = []; for (var i = 0; i < stepNum; i++) { var offset = unit * i + '%'; var style = { left: offset }; var className = prefixClsFn(prefixCls, 'dot'); if (props.isIncluded) { if (i <= this.getIndex()) { className = prefixClsFn(prefixCls, 'dot', 'dot-active'); } } else { className = i === this.getIndex() ? prefixClsFn(prefixCls, 'dot', 'dot-active') : className; } elements[i] = _react2['default'].createElement('span', { className: className, style: style, ref: 'step' + i, key: 'step' + i }); } return _react2['default'].createElement( 'div', { className: stepClassName }, elements ); }, renderMark: function renderMark(i) { var marks = this.props.marks; var marksLen = marks.length; var unit = 100 / (marksLen - 1); var offset = unit * i; var style = { width: unit / 2 + '%' }; if (i === marksLen - 1) { style.right = -unit / 4 + '%'; } else { style.left = i > 0 ? offset - unit / 4 + '%' : -unit / 4 + '%'; } var prefixCls = this.props.prefixCls; var className = prefixClsFn(prefixCls, 'mark-text'); if (this.props.isIncluded) { if (i <= this.getIndex()) { className = prefixClsFn(prefixCls, 'mark-text', 'mark-text-active'); } } else { className = i === this.getIndex() ? prefixClsFn(prefixCls, 'mark-text', 'mark-text-active') : className; } return _react2['default'].createElement( 'span', { className: className, style: style, key: i }, this.props.marks[i] ); }, renderMarks: function renderMarks() { var marks = this.props.marks; var marksLen = marks.length; var elements = []; for (var i = 0; i < marksLen; i++) { elements[i] = this.renderMark(i); } var prefixCls = this.props.prefixCls; var className = prefixClsFn(prefixCls, 'mark'); return _react2['default'].createElement( 'div', { className: className }, elements ); }, renderHandler: function renderHandler(offset) { var onStyle = { left: offset }; var prefixCls = this.props.prefixCls; var className = prefixClsFn(prefixCls, 'handle'); var events = {}; var tooltipVisible = undefined; if (this.state.dragging) { tooltipVisible = true; } else { events = { onClick: this.showTooltip.bind(this, true), onMouseEnter: this.showTooltip.bind(this, true), onMouseLeave: this.showTooltip.bind(this, false) }; tooltipVisible = this.state.showTooltip; } var handle = _react2['default'].createElement('div', _extends({ className: className }, events, { ref: 'handle', style: onStyle })); if (this.props.marks.length > 0) { return handle; } return _react2['default'].createElement( _rcTooltip2['default'], { placement: { points: ['bc', 'tc'] }, visible: tooltipVisible, overlay: _react2['default'].createElement( 'span', null, this.state.value ), delay: 0, transitionName: this.props.tipTransitionName, prefixCls: prefixClsFn(prefixCls, 'tooltip') }, handle ); }, renderTrack: function renderTrack(offset) { var style = { width: offset }; var prefixCls = this.props.prefixCls; var trackClassName = prefixClsFn(prefixCls, 'track'); return _react2['default'].createElement('div', { className: trackClassName, ref: 'track', style: style }); }, render: function render() { var _sliderClassName; var state = this.state; var props = this.props; var value = state.value; var offset = this._calcOffset(value); var track = this.props.isIncluded ? this.renderTrack(offset) : null; var ons = this.renderHandler(offset); var steps = props.step > 1 || props.marks.length > 0 ? this.renderSteps() : null; var sliderMarks = props.marks.length > 0 ? this.renderMarks() : null; var prefixCls = props.prefixCls; var disabled = props.disabled; var sliderClassName = (_sliderClassName = {}, _defineProperty(_sliderClassName, prefixCls, 1), _defineProperty(_sliderClassName, props.className, !!props.className), _defineProperty(_sliderClassName, prefixCls + '-disabled', disabled), _sliderClassName); return _react2['default'].createElement( 'div', { className: _rcUtil2['default'].classSet(sliderClassName), ref: 'slider', onTouchStart: disabled ? noop : this.onTouchStart, onMouseDown: disabled ? noop : this.onSliderMouseDown }, track, ons, steps, sliderMarks, this.props.children ); }, showTooltip: function showTooltip(show) { this.setState({ showTooltip: show }); }, _trimAlignValue: function _trimAlignValue(v, propsArg) { var val = v; var props = propsArg || this.props; var step = props.marks.length > 0 ? (props.max - props.min) / (props.marks.length - 1) : props.step; if (val <= props.min) { val = props.min; } if (val >= props.max) { val = props.max; } var valModStep = (val - props.min) % step; var alignValue = val - valModStep; if (Math.abs(valModStep) * 2 >= step) { alignValue += valModStep > 0 ? step : -step; } return parseFloat(alignValue.toFixed(5)); }, _calcOffset: function _calcOffset(value) { var ratio = (value - this.props.min) / (this.props.max - this.props.min); return ratio * 100 + '%'; }, _calcValue: function _calcValue(offset) { var ratio = offset / this.getSliderLength(); return ratio * (this.props.max - this.props.min) + this.props.min; }, _calValueByPos: function _calValueByPos(position) { var pixelOffset = position - this.getSliderStart(); // pixelOffset -= (this.state.onSize / 2); var nextValue = this._trimAlignValue(this._calcValue(pixelOffset)); this.setState({ value: nextValue }); return nextValue; }, _getTouchPosition: function _getTouchPosition(e) { var touch = e.touches[0]; return touch.pageX; }, _triggerEvents: function _triggerEvents(event, v) { var props = this.props; var hasMarks = props.marks && props.marks.length > 0; if (props[event]) { var data = undefined; if (hasMarks) { data = this.getIndex(v); } else if (v === undefined) { data = this.state.value; } else { data = v; } props[event](data); } }, _addDocumentEvents: function _addDocumentEvents(type) { if (type === 'touch') { // just work for chrome iOS Safari and Android Browser this.onTouchMoveListener = _rcUtil.Dom.addEventListener(document, 'touchmove', this.onTouchMove); this.onTouchUpListener = _rcUtil.Dom.addEventListener(document, 'touchend', this.onTouchUp); } else if (type === 'mouse') { this.onMouseMoveListener = _rcUtil.Dom.addEventListener(document, 'mousemove', this.onMouseMove); this.onMouseUpListener = _rcUtil.Dom.addEventListener(document, 'mouseup', this.onMouseUp); } }, _removeEventons: function _removeEventons(type) { if (type === 'touch') { this.onTouchMoveListener.remove(); this.onTouchUpListener.remove(); } else if (type === 'mouse') { this.onMouseMoveListener.remove(); this.onMouseUpListener.remove(); } }, _start: function _start(position, value) { this._triggerEvents('onBeforeChange'); this.startValue = value; this.startPosition = position; this.setState({ dragging: true }); }, _end: function _end(type, showToolTip) { this._removeEventons(type); this._triggerEvents('onAfterChange'); this.setState({ dragging: false, showTooltip: !!showToolTip }); } }); exports['default'] = Slider; module.exports = exports['default']; /***/ }, /* 291 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _enterAnimation = __webpack_require__(292); var _enterAnimation2 = _interopRequireDefault(_enterAnimation); var AntEnterAnimation = (function (_React$Component) { _inherits(AntEnterAnimation, _React$Component); function AntEnterAnimation() { _classCallCheck(this, AntEnterAnimation); _get(Object.getPrototypeOf(AntEnterAnimation.prototype), 'constructor', this).apply(this, arguments); } _createClass(AntEnterAnimation, [{ key: 'render', value: function render() { return _react2['default'].createElement(_enterAnimation2['default'], this.props); } }]); return AntEnterAnimation; })(_react2['default'].Component); AntEnterAnimation.to = _enterAnimation2['default'].to; exports['default'] = AntEnterAnimation; module.exports = exports['default']; /***/ }, /* 292 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(293); /***/ }, /* 293 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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) subClass.__proto__ = superClass; } var _react = __webpack_require__(76); //import assign from 'object-assign'; var _react2 = _interopRequireDefault(_react); var _EnterAnimationChild = __webpack_require__(294); var _EnterAnimationChild2 = _interopRequireDefault(_EnterAnimationChild); var _EnterUtils = __webpack_require__(295); var startAnimation = __webpack_require__(296); var EnterAnimation = (function (_Component) { _inherits(EnterAnimation, _Component); function EnterAnimation(props) { var _this = this; _classCallCheck(this, EnterAnimation); _get(Object.getPrototypeOf(EnterAnimation.prototype), 'constructor', this).apply(this, arguments); this.keysToEnter = []; this.keysToLeave = []; //第一次进入,默认进场; var elementArr = (0, _EnterUtils.toArrayChildren)(this.props.children); elementArr.map(function (m) { if (!m || !m.key) { return; } _this.keysToEnter.push(m.key); }); this.childWapArr = (0, _EnterUtils.deleteRepeatKeyArr)(elementArr); this.state = { childWapArr: this.childWapArr }; } _createClass(EnterAnimation, [{ key: 'setData', value: function setData(props, wap) { this.setState({ enter: props.enter, leave: props.leave, childWapArr: wap }); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { //添加出场时的position: absolute; //if (this.keysToEnter.length) { // this.keysToLeave.map((key)=> { // this.state.childWapArr.map((m)=> { // if (key == m.key) { // m.props.style = {position: "absolute"}; // console.log(m) // } // }) // }) //} this.childWapArr = (0, _EnterUtils.deleteRepeatKeyArr)((0, _EnterUtils.toArrayChildren)(this.props.children)); this.keysToLeave = []; this.keysToEnter = []; } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { var _this2 = this; var newChildrenArr = (0, _EnterUtils.deleteRepeatKeyArr)((0, _EnterUtils.toArrayChildren)(nextProps.children)); var currentChildWapArr = this.childWapArr; var leaveChildArr = []; //增加absolute,所以把进场的也放数组里。。 var enterChildArr = []; this.keysToLeave = []; this.keysToEnter = []; //判断两Arr里的不同; (0, _EnterUtils.contrastArr)(currentChildWapArr, newChildrenArr, function (cm) { if (cm.key) { _this2.keysToEnter.push(cm.key); enterChildArr.push(cm); //newChildrenArr.splice(newChildrenArr.indexOf(cm), 1);//清掉进场的; } }); //清掉进场; enterChildArr.map(function (cm) { newChildrenArr.splice(newChildrenArr.indexOf(cm), 1); }); (0, _EnterUtils.contrastArr)(newChildrenArr, currentChildWapArr, function (cm) { if (cm.key) { leaveChildArr.push(cm); _this2.keysToLeave.push(cm.key); //newChildrenArr.splice(newChildrenArr.indexOf(cm), 1);//清掉出场的; } }); //newChildrenArr = leaveChildArr.concat(newChildrenArr); ////清掉出场; //leaveChildArr.map((cm)=>{ // newChildrenArr.splice(newChildrenArr.indexOf(cm), 1); //}); newChildrenArr = newChildrenArr.concat(leaveChildArr, enterChildArr); this.setData(nextProps, (0, _EnterUtils.deleteRepeatKeyArr)(newChildrenArr)); return false; } }, { key: 'kill', value: function kill() { this.setData(this.props, this.childWapArr); } }, { key: 'start', value: function start(h) { //findDOMNode(this).style.height = h + 'px'; //获取Enter的元素里的高。。 } }, { key: 'render', value: function render() { var _this3 = this; var props = this.props; var childrenToRender = this.state.childWapArr.map(function (m) { if (!m || !m.key) { return m; } var direction = _this3.keysToEnter.indexOf(m.key) >= 0 ? 'enter' : _this3.keysToLeave.indexOf(m.key) >= 0 ? 'leave' : null; var posBool = false; if (_this3.keysToEnter.length) { _this3.keysToLeave.map(function (key) { if (key === m.key) { posBool = true; } }); } return _react2['default'].createElement( _EnterAnimationChild2['default'], { key: m.key, ref: m.key, direction: direction, enter: props.enter, leave: props.leave, position: posBool, callback: _this3.kill.bind(_this3), onStart: _this3.start.bind(_this3) }, m ); }); //去重复和null childrenToRender = (0, _EnterUtils.deleteRepeatKeyArr)(childrenToRender); return (0, _react.createElement)(props.component, props, childrenToRender); } }]); return EnterAnimation; })(_react.Component); EnterAnimation.to = startAnimation; EnterAnimation.propTypes = { component: _react2['default'].PropTypes.string }; EnterAnimation.defaultProps = { component: 'div' }; exports['default'] = EnterAnimation; module.exports = exports['default']; /***/ }, /* 294 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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) subClass.__proto__ = superClass; } var _react = __webpack_require__(76); var _EnterUtils = __webpack_require__(295); var startAnimation = __webpack_require__(296); //const defaultKey = 'enter_' + Date.now(); var EnterAnimationChild = (function (_Component) { _inherits(EnterAnimationChild, _Component); function EnterAnimationChild(props) { _classCallCheck(this, EnterAnimationChild); _get(Object.getPrototypeOf(EnterAnimationChild.prototype), 'constructor', this).apply(this, arguments); this.state = { enter: props.enter, leave: props.leave, children: this.props.children }; this.dataArr = []; this.key = []; this.direction = ''; this.defaultType = !this.state.enter && !this.state.leave ? 'right' : this.direction === 'leave' ? this.state.leave.type || this.state.leave.style || this.state.enter.type || this.state.enter.style || 'right' : this.state.enter.type || this.state.enter.style || 'right'; } /*遍历children里的dataEnter*/ _createClass(EnterAnimationChild, [{ key: 'callChildrenDataEnter', value: function callChildrenDataEnter(props, mc, arr, i) { var self = this, enter, leave; arr[i] = { enter: {}, leave: {} }; if (props) { enter = (0, _EnterUtils.isPropsPushData)(props['enter-data'], props['data-enter'], self.defaultType); leave = (0, _EnterUtils.isPropsPushData)(props['leave-data'], props['data-leave'], enter.type || enter.style || self.defaultType); arr[i].enter = enter; //出场如果没有效果,继承进场效果; arr[i].leave = (0, _EnterUtils.leaveInherit)(leave, enter); if (typeof props.children === 'object') { arr[i].children = []; self.componentChildrenDataEnter(props.children, mc.children, arr[i].children); } } else { var _enter = mc.getAttribute('data-enter'), _leave = mc.getAttribute('data-leave'); enter = (0, _EnterUtils.noPropsPushData)(_enter, self.defaultType); leave = (0, _EnterUtils.noPropsPushData)(_leave, enter.type || enter.style || self.defaultType); arr[i].enter = enter; arr[i].leave = (0, _EnterUtils.leaveInherit)(leave, enter); if (mc.children.length > 0) { arr[i].children = []; self.componentChildrenDataEnter(null, mc.children, arr[i].children); } } if (arr[i].enter.type || arr[i].enter.style || arr[i].leave.type || arr[i].leave.style) { self.dataArr.cBool = true; } } }, { key: 'componentChildrenDataEnter', value: function componentChildrenDataEnter(children, dom, arr) { var self = this, props = undefined, mc = undefined; if (children && typeof children === 'object' && children.length) { //有react时 //要处理children里的enter-data,dom里的data-enter; children.map(function (re, i) { props = re.props; mc = dom[i]; self.callChildrenDataEnter(props, mc, arr, i); }); } else if (children) { props = children ? children.props : null; self.callChildrenDataEnter(props, dom[0], arr, 0); } else if (dom) { //router时; for (var i = 0; i < dom.length || 0; i++) { mc = dom[i]; self.callChildrenDataEnter(null, mc, arr, i); } } else { return console.warn('Warning: Not perform EnterAnimation, Children is null.'); } } }, { key: 'callEnterAnimation', value: function callEnterAnimation(dom, wap) { var _this = this; var state = this.state; var enter = state.enter || {}, leave = state.leave || null; var transition = this.dataArr; var direction = this.direction; if (!this.dataArr.cBool) { transition = enter.type || enter.style || 'right'; if (direction === 'leave' && leave) { transition = leave.type || leave.style || transition; } } var callFunc = function callFunc() { enter.callback.call(_this, { ReactElement: wap, target: dom, direction: direction }); }; var callBack = typeof enter.callback === 'function' ? callFunc : null, reverse = enter.reverse, duration = enter.duration, delay = enter.delay, interval = enter.interval, ease = enter.ease; if (direction === 'leave') { callBack = function () { //动画后; if (leave && typeof leave.callback === 'function') { leave.callback.call(_this, { ReactElement: wap, target: dom, direction: direction }); } else if (typeof enter.callback === 'function') { enter.callback.call(_this, { ReactElement: wap, target: dom, direction: direction }); } //出场周期结束; _this.props.callback.call(_this, wap, direction); }; //大标签上的继承 if (leave) { reverse = leave.reverse || enter.reverse; duration = typeof leave.duration === 'number' ? leave.duration : enter.duration; delay = typeof leave.delay === 'number' ? leave.delay : enter.delay; interval = typeof leave.interval === 'number' ? leave.interval : enter.interval; ease = leave.ease || enter.ease; } } startAnimation(dom, { duration: duration, data: transition, delay: delay, direction: direction, interval: interval, reverse: reverse, ease: ease, onComplete: callBack }); } }, { key: 'setDomKey', value: function setDomKey() { //取出dom下的要做动画的节点,如果没key,自动加上 var dom = (0, _react.findDOMNode)(this); if (typeof this.props.children === 'string') { return console.warn('Warning: Not perform EnterAnimation, Elements is String(' + this.props.children + ').'); } if (typeof dom.children === 'string') { return console.warn('Warning: Not perform EnterAnimation, Elements is String(' + dom.children + ').'); } var children = this.props.children instanceof Array ? this.props.children : this.props.children.props.children; var domChildren = dom.children.length >= 1 ? dom.children : dom.children.children; if (typeof children === 'string') { return console.warn('Warning: Not perform EnterAnimation, Elements is String(' + children + ').'); } if (typeof domChildren === 'string') { return console.warn('Warning: Not perform EnterAnimation, Elements is String(' + domChildren + ').'); } //dom的data-enter或reactElement的props的enter-data; this.componentChildrenDataEnter(children, domChildren, this.dataArr); //console.log(this.dataArr) } }, { key: 'componentDidMount', value: function componentDidMount() { //第一次进入;默认给enter; this.direction = 'enter'; this.componentWillReceiveProps(this.props); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { var dom = (0, _react.findDOMNode)(this); var wap = this.props.children; if (this.props.direction) { this.props.onStart(); this.direction = this.props.direction; this.callEnterAnimation(dom, wap); } } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { //要对新插入元素做动画; if (nextProps.direction) { var dom = (0, _react.findDOMNode)(this); if (nextProps.position) { dom.style.position = 'absolute'; } else { dom.style.position = ''; } this.direction = nextProps.direction; this.defaultType = !nextProps.enter && !nextProps.leave ? 'right' : this.direction === 'leave' && nextProps.leave ? nextProps.leave.type || nextProps.leave.style || nextProps.enter.type || nextProps.enter.style || 'right' : nextProps.enter.type || nextProps.enter.style || 'right'; this.setDomKey(); this.setState({ enter: nextProps.enter, leave: nextProps.leave }); } } }, { key: 'render', value: function render() { return this.props.children; } }]); return EnterAnimationChild; })(_react.Component); exports['default'] = EnterAnimationChild; module.exports = exports['default']; /***/ }, /* 295 */ /***/ function(module, exports, __webpack_require__) { /** * Created by jljsj on 15/9/1. */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var utils = { toArrayChildren: function toArrayChildren(children) { var ret = []; _react2['default'].Children.forEach(children, function (c) { ret.push(c); }); return ret; }, //getChildrenFromProps: function (props) { // const children = props.children; // if (React.isValidElement(children)) { // if (!children.key) { // return React.cloneElement(children, { // key: defaultKey // }); // } // } // return obj; //}, extend: function extend(des, src, override) { var i = undefined, len = src.length; if (src instanceof Array) { for (i = 0; i < len; i++) { utils.extend(des, src[i], override); } } else { for (i in src) { if (override || !(i in des)) { des[i] = src[i]; } } } return des; }, deleteRepeatKeyArr: function deleteRepeatKeyArr(arr) { var result = [], hash = {}; for (var i = 0; i < arr.length; i++) { var elem = arr[i]; if (elem) { if (elem.key) { if (elem && !hash[elem.key]) { result.push(elem); hash[elem.key] = true; } } else { result.push(elem); } } } return result; }, contrastArr: function contrastArr(_a, _b, callback) { var _this = this; var a = _a, b = _b.concat(); if (a.length === 0) { b.map(function (m) { callback.call(_this, m); }); } else { a.map(function (m) { if (!m || !m.key) { return; } for (var i = 0; i < b.length; i++) { var cm = b[i]; if (!cm || !cm.key || cm.key === m.key) { b.splice(i, 1); } } }); b.map(function (m) { callback.call(_this, m); }); } }, isPropsPushData: function isPropsPushData(data, tagData, enterDataType) { var _data = {}; if (data || tagData) { data = data || {}; if (typeof data === 'boolean') { data = {}; } if (typeof tagData === 'string') { tagData = JSON.parse(tagData); } tagData = tagData || {}; _data = utils.extend({}, [data, tagData]); if (!_data.type && !_data.style) { _data.type = enterDataType; } } return _data; }, noPropsPushData: function noPropsPushData(tagData, enterDataType) { if (typeof tagData === 'string') { tagData = JSON.parse(tagData); } if (tagData) { if (typeof tagData === 'boolean') { tagData = {}; } if (!tagData.type && !tagData.style) { tagData.type = enterDataType; } } return tagData || {}; }, leaveInherit: function leaveInherit(leave, enter) { if (leave.type || enter.type) { leave.type = leave.type || enter.type; } if (leave.style || enter.style) { leave.style = leave.style || enter.style; } if (typeof leave.duration === 'number' || enter.duration) { leave.duration = typeof leave.duration === 'number' ? leave.duration : enter.duration; } if (leave.ease || enter.ease) { leave.ease = leave.ease || enter.ease; } if (typeof leave.delay === 'number' || enter.delay) { leave.delay = typeof leave.delay === 'number' ? leave.delay : enter.delay; } if (typeof leave.queueId === 'number' || enter.queueId) { leave.queueId = typeof leave.queueId === 'number' ? leave.queueId : enter.queueId; } return leave; } }; exports['default'] = utils; module.exports = exports['default']; /***/ }, /* 296 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var Css = __webpack_require__(297); var Event = __webpack_require__(298); var cssStr = ''; var startAnim = function startAnim(node, vars) { //判断浏览,ie10以下不支持; if (!(this.getTransition() in document.documentElement.style)) { if (vars && typeof vars.onComplete === 'function') { vars.onComplete(); } return false; } if (!vars) { vars = {}; } this.nodeStr = node; this.doc = document; this.tweenData = typeof vars.data === 'object' && vars.data.cBool ? vars.data : null; this.str = typeof vars.data === 'string' ? vars.data : 'right'; this.delay = typeof vars.delay === 'number' ? vars.delay * 1000 : 30; this.interval = typeof vars.interval === 'number' ? vars.interval : 0.1; this.direction = vars.direction || 'enter'; this.__ease = vars.ease || 'cubic-bezier(0.165, 0.84, 0.44, 1)'; this.__timer = typeof vars.duration === 'number' ? vars.duration : 0.5; this.reverse = vars.reverse || false; var hidden = typeof vars.hidden === 'undefined' ? true : vars.hidden; this.callback = vars.onComplete; this.kill = true; if (hidden) { this.doc.documentElement.style.opacity = 0; this.doc.documentElement.style.visibility = 'hidden'; } cssStr += cssStr !== this.str + ';' ? this.str + ';' : ''; setTimeout(function () { cssStr = ''; }, 1000); //1秒后清掉样式 this.init(); }; var a = startAnim.prototype = []; a.addClass = Css.addClass; a.removeClass = Css.removeClass; a.addStyle = Css.addStyle; a.removeStyle = Css.removeStyle; a.getTransform = Event.getTransform; a.getTransition = Event.getTransition; a.getAnimation = Event.getAnimation; a.error = function (msg) { throw new Error(msg); }; a.init = function () { var self = this, regTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; //rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/; var htmlStyle = self.doc.documentElement; self.removeStyle(htmlStyle, 'visibility:hidden;opacity:0'); if (htmlStyle.style.length <= 0) { self.doc.documentElement.removeAttribute('style'); } if (!self.nodeStr || regTag.test(self.nodeStr)) { return self.error('node error;'); } if (typeof self.nodeStr === 'string') { //var m=rquickExpr.exec(self.nodeStr); self.push.apply(self, self.doc.querySelectorAll(self.nodeStr)); } else if (typeof self.nodeStr === 'object') { if (self.nodeStr.length) { self.push.apply(self, self.nodeStr); } else { self.push(self.nodeStr); } } if (!self.length) { return self.error('node error;'); } var _mc = self.length === 1 ? self[0].children : self; //默认值 self.__delay = 0; self.queueIdArr = []; //管理分支队延时间; self.__ease = self.__ease || 'cubic-bezier(0.165, 0.84, 0.44, 1)'; self.__timer = self.__timer || 0.5; self.__qId = 0; self.forTweenData(_mc, self.tweenData, function (mc, data) { if (self.kill) { var s = ''; for (var c = 0; c < cssStr.split(';').length; c++) { s += self.animNameGroup(cssStr.split(';')[c]) + ';'; } self.removeStyle(mc, 'transition;' + s, true); } if (data) { var direction = data.direction || self.direction; var sBool = data.enter.type || data.enter.style || data.leave.type || data.leave.style; if (!data.children && !sBool && direction === 'leave') { //self.addStyle(mc, 'opacity:0'); } if (direction === 'leave') { data = data.leave; } else { data = data.enter; } if (data.type || data.style || typeof data.duration === 'number' || data.ease || typeof data.delay === 'number' || typeof data.queueId === 'number') { if (self.reverse) { //判断分支; self.__qId = data.queueId || 0; //判断延时; if (!self.queueIdArr[self.__qId] && self.queueIdArr[self.__qId] !== 0) { self.queueIdArr[self.__qId] = 0 + (data.delay || 0); } else { self.queueIdArr[self.__qId] = Number(Number(self.queueIdArr[self.__qId] + (data.delay || 0) + self.interval).toFixed(3)); } } var _style = data.type || data.style || self.str; if (_style) { if (direction === 'leave') { self.removeStyle(mc, self.animNameGroup(_style)); } else { self.addStyle(mc, self.animNameGroup(_style)); } } } } else { if (self.reverse) { if (!self.queueIdArr[self.__qId] && self.queueIdArr[self.__qId] !== 0) { self.queueIdArr[self.__qId] = 0; } else { self.queueIdArr[self.__qId] = Number(Number(self.queueIdArr[self.__qId] + self.interval).toFixed(3)); } } if (self.direction === 'leave') { self.removeStyle(mc, self.animNameGroup(self.str)); } else { self.addStyle(mc, self.animNameGroup(self.str)); } } if (!data || data && (data.type || data.style)) { self.enterLength = self.enterLength ? self.enterLength + 1 : 1; } }); //出场隐掉没动画的。 self.leaveHideNull(_mc, self.tweenData); setTimeout(function () { self.addTween(); }, self.delay); }; a.leaveHideNull = function (mc, data) { var self = this; var tm = mc.children || mc; if (data) { for (var i = 0; i < data.length; i++) { var _d = data[i], _m = tm[i]; var e_d = _d.enter, l_d = _d.leave, e_data = e_d.type || e_d.style || typeof e_d.duration === 'number' || e_d.ease || typeof e_d.delay === 'number' || typeof e_d.queueId === 'number', l_data = l_d.type || l_d.style || typeof l_d.duration === 'number' || l_d.ease || typeof l_d.delay === 'number' || typeof l_d.queueId === 'number'; var direction = l_d.direction || self.direction; if (!e_data && !l_data && !_d.children && direction === 'leave') { self.addStyle(mc[i], 'opacity:0'); } else if (!e_data && !l_data && _m.children && _d.children && direction === 'leave') { self.leaveHideNull(_m.children, _d.children); } } } }; //遍历dom节点; a.forTweenData = function (mc, data, callFunc, animBool) { if (!mc) { if (!animBool) { console.log('Data redundancy:' + JSON.stringify(data)); } return; } var tm = mc.children || mc, self = this; if (data) { if (data.length) { data.map(function (m, ii) { if (m.length) { self.forTweenData(tm[ii], m, callFunc, animBool); } else if (m.children) { callFunc(tm[ii], m); self.forTweenData(tm[ii], m, callFunc, animBool); } else { callFunc(tm[ii], m); } }); } else if (data.children && data.children.length) { data.children.map(function (m, ii) { if (m.length) { self.forTweenData(tm[ii], m, callFunc, animBool); } else if (m.children) { callFunc(tm[ii], m); self.forTweenData(tm[ii], m, callFunc, animBool); } else { callFunc(tm[ii], m); } }); } else { self.error('data(' + data + ') is error'); } } else { for (var i = 0; i < tm.length; i++) { callFunc(tm[i], null); } } }; a.fjStyle = function (node, style, tweenStr) { var self = this; if (typeof style === 'object') { for (var _s in style) { _s = _s.indexOf('margin') >= 0 ? 'margin' : _s.indexOf('padding') >= 0 ? 'padding' : _s.indexOf('background') >= 0 ? 'background' : _s.indexOf('border') >= 0 ? 'border' : _s.indexOf('stroke') >= 0 ? 'stroke' : _s === 'textShadow' ? 'text-shadow' : _s === 'textTransform' ? 'text-transform' : _s; node.style[self.getTransition()] = node.style[self.getTransition()] ? node.style[self.getTransition()] + ',' + _s + tweenStr : _s + tweenStr; } } else { var cArr = style.trim().split(';'); for (var i = 0; i < cArr.length; i++) { if (cArr[i] && cArr[i] !== '') { var sArr = cArr[i].split(':'); node.style[self.getTransition()] = node.style[self.getTransition()] ? node.style[self.getTransition()] + ',' + sArr[0] + tweenStr : sArr[0] + tweenStr; } } } }; a.addTween = function () { //查找tweenDataArr与dom下子级的匹配; var self = this, eNum = 0; var m = self.length === 1 ? self[0].children : self; self.forTweenData(m, self.tweenData, function (mc, data) { var tweenStr = ' ' + self.__timer + 's ' + self.__ease + ' ' + self.__delay + 's'; var _style = null; if (data) { var direction = data.direction || self.direction; if (direction === 'leave') { data = data.leave; } else { data = data.enter; } if (data.type || data.style || typeof data.duration === 'number' || data.ease || typeof data.delay === 'number' || typeof data.queueId === 'number') { //判断分支; self.__qId = data.queueId || 0; //判断延时; if (self.reverse) { self.queueIdArr[self.__qId] = Number(Number((self.queueIdArr[self.__qId] || 0) - (data.delay || 0)).toFixed(3)); self.__delay = Number(Number(self.queueIdArr[self.__qId] + (data.delay || 0)).toFixed(3)); } else { self.queueIdArr[self.__qId] = Number(Number((self.queueIdArr[self.__qId] || 0) + (data.delay || 0)).toFixed(3)); self.__delay = self.queueIdArr[self.__qId]; } var _ease = data.ease || self.__ease, _timer = typeof data.duration === 'number' ? data.duration : self.__timer; tweenStr = ' ' + _timer + 's ' + _ease + ' ' + self.__delay + 's'; _style = data.type || data.style; if (_style) { var _name = self.animNameGroup(_style); self.fjStyle(mc, _name, tweenStr); if (direction === 'leave') { self.addStyle(mc, _name); } else { self.removeStyle(mc, _name); } } } } else { self.queueIdArr[self.__qId] = self.queueIdArr[self.__qId] || 0; self.__delay = self.queueIdArr[self.__qId] || self.queueIdArr[self.__qId] === 0 ? self.queueIdArr[self.__qId] : self.__delay; tweenStr = ' ' + self.__timer + 's ' + self.__ease + ' ' + self.__delay + 's'; self.fjStyle(mc, self.animNameGroup(self.str), tweenStr); if (self.direction === 'leave') { self.addStyle(mc, self.animNameGroup(self.str)); } else { self.removeStyle(mc, self.animNameGroup(self.str)); } } if (!data || data && (data.type || data.style)) { mc.setAttribute('delay', self.__delay); if (self.reverse) { if (self.queueIdArr[self.__qId] > 0) { self.queueIdArr[self.__qId] -= self.interval; } } else { self.queueIdArr[self.__qId] += self.interval; } setTimeout(function () { Event.setTrnsitionEnd(mc, function () { eNum++; if (eNum >= self.enterLength) { if (typeof self.callback === 'function') { self.callback(); } } }); }, self.__delay * 1000); } }, true); }; a.animNameGroup = function (name) { var _style = '', self = this; switch (name) { case 'alpha': _style = 'opacity:0'; break; case 'left': _style = self.getTransform() + ':translateX(-30px);opacity:0'; break; case 'right': _style = self.getTransform() + ':translateX(30px);opacity:0;'; break; case 'bottom': _style = self.getTransform() + ':translateY(30px);opacity:0'; break; case 'top': _style = self.getTransform() + ':translateY(-30px);opacity:0'; break; case 'scale': _style = self.getTransform() + ':scale(0);opacity:0'; break; case 'scaleBig': _style = self.getTransform() + ':scale(2);opacity:0'; break; case 'scaleX': _style = self.getTransform() + ':scaleX(0);opacity:0'; break; case 'scaleY': _style = self.getTransform() + ':scaleY(0);opacity:0'; break; default: _style = name; break; } return _style; }; var startAnimation = function startAnimation(node, vars) { return new startAnim(node, vars); }; module.exports = startAnimation; /***/ }, /* 297 */ /***/ function(module, exports) { 'use strict'; module.exports = { addClass: function addClass(m, value) { //添加样式类 if (!m) { return false; } var _classname = m.className, s_k = ' '; if (_classname.indexOf(value) < 0) { m.className += s_k + value; } m.className = m.className.trim(); }, removeClass: function removeClass(m, value) { //删除样式类 if (!m) { return false; } var rclass = /[\t\r\n\f]/g; var _classname = (' ' + m.className + ' ').replace(' ' + rclass + ' ', ' '); while (_classname.indexOf(value) >= 0) { _classname = _classname.replace(value, ' '); } m.className = _classname.trim(); if (!m.className || m.className === '' || m.className === ' ') { m.removeAttribute('class'); } }, addStyle: function addStyle(m, style) { //添加style if (!m) { return false; } if (typeof style === 'object') { for (var _s in style) { m.style[_s] = style[_s]; } } else { var _style = m.getAttribute('style') || ''; _style += style; m.setAttribute('style', _style); } }, removeStyle: function removeStyle(m, style, oneBool) { //删除style; if (!m) { return false; } if (typeof style === 'object') { for (var _s in style) { m.style[_s] = ''; } } else { var cArr = style.trim().split(';'); cArr.map(function (arr) { if (arr && arr !== '') { var carr = m.style.cssText.split(';'), cOne = arr.split(':')[0].replace(/\s/g, ''), cTow = arr.split(':')[1] ? arr.split(':')[1].replace(/\s/g, '') : ''; carr.map(function (_arr) { if (_arr && _arr !== '') { var tcOne = _arr.split(':')[0].replace(/\s/g, ''), tcTow = _arr.split(':')[1].replace(/\s/g, ''); if (oneBool && tcOne.indexOf(cOne) >= 0) { m.style[arr.split(':')[0]] = ''; } else if (tcOne.indexOf(cOne) >= 0 && tcTow === cTow) { m.style[arr.split(':')[0]] = ''; } } }); } }); } } }; /***/ }, /* 298 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var Css = __webpack_require__(297); module.exports = { getTransform: function getTransform() { var style = 'transform'; if (!(style in document.documentElement.style)) { var prefix = ['webkit', 'moz', 'ms', 'o']; for (var i in prefix) { style = '-' + prefix[i] + '-transform'; if (style in document.documentElement.style) { break; } } } return style; }, getTransition: function getTransition() { var style = 'transition'; if (!(style in document.documentElement.style)) { var prefix = ['webkit', 'moz', 'ms', 'o']; for (var i in prefix) { style = '-' + prefix[i] + '-transition'; if (style in document.documentElement.style) { break; } } } return style; }, getAnimation: function getAnimation() { var style = 'animation'; if (!(style in document.documentElement.style)) { var prefix = ['webkit', 'moz', 'ms', 'o']; for (var i in prefix) { style = '-' + prefix[i] + '-animation'; if (style in document.documentElement.style) { break; } } } return style; }, whichAnimationEvent: function whichAnimationEvent() { var animation = { 'animation': 'animationend', 'oAnimation': 'oanimationend', 'MozAnimation': 'mozAnimationEnd', 'WebkitAnimation': 'webkitAnimationEnd', 'msAnimation': 'MSAnimationEnd' }; for (var t in animation) { if (t in document.documentElement.style) { return animation[t]; } } }, whichTransitionEvent: function whichTransitionEvent() { var transitions = { 'transition': 'transitionend', 'OTransition': 'oTransitionEnd', 'MozTransition': 'transitionend', 'WebkitTransition': 'webkitTransitionEnd' }; for (var t in transitions) { if (t in document.documentElement.style) { return transitions[t]; } } }, setAnimEventEnd: function setAnimEventEnd(mc, css, style) { var animationEvent = this.whichAnimationEvent(); function _event() { if (document.addEventListener) { mc.removeEventListener(animationEvent, _event); } else { window.detachEvent(animationEvent, _event); } Css.removeClass(mc, css); Css.removeStyle(mc, style); } if (document.addEventListener) { mc.addEventListener(animationEvent, _event); } else { mc.attachEvent(animationEvent, _event); } }, setTrnsitionEnd: function setTrnsitionEnd(mc, callback, rem) { var transitionEvent = this.whichTransitionEvent(); var self = this; function _event(e) { if (document.addEventListener) { mc.removeEventListener(transitionEvent, _event); } else { window.detachEvent(transitionEvent, _event); } Css.removeStyle(mc, 'opacity:1;visibility:visible'); if (mc.getAttribute('style')) { var s = mc.getAttribute('style').split(';'); var i = 0, _style = ''; while (i < s.length) { if (s[i] !== '') { if (s[i].indexOf(mc.style[self.getTransition()]) >= 0 && mc.style[self.getTransition()] && mc.style[self.getTransition()] !== '') { s[i] = ''; } //这里的判断为改变s[i]值后的判断 if (s[i] !== '') { _style += s[i] + ';'; } } i++; } if (!_style || _style.replace(/\s/g, '') === '') { mc.removeAttribute('style'); } else { mc.setAttribute('style', _style); } } mc.removeAttribute('delay'); if (typeof callback === 'function') { callback(); } } if (document.addEventListener) { mc.addEventListener(transitionEvent, _event); } else { mc.attachEvent(transitionEvent, _event); } } }; /***/ }, /* 299 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _radio = __webpack_require__(300); var _radio2 = _interopRequireDefault(_radio); var _group = __webpack_require__(303); var _group2 = _interopRequireDefault(_group); _radio2['default'].Group = _group2['default']; exports['default'] = _radio2['default']; module.exports = exports['default']; /***/ }, /* 300 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rcRadio = __webpack_require__(301); var _rcRadio2 = _interopRequireDefault(_rcRadio); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var AntRadio = _react2['default'].createClass({ displayName: 'AntRadio', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-radio' }; }, render: function render() { var classString = this.props.className; if (classString) { classString += this.props.checked ? ' ' + classString + '-checked' : ''; } return _react2['default'].createElement( 'label', { className: classString }, _react2['default'].createElement(_rcRadio2['default'], _extends({}, this.props, { children: null })), this.props.children ); } }); var Button = _react2['default'].createClass({ displayName: 'Button', getDefaultProps: function getDefaultProps() { return { className: 'ant-radio-button' }; }, render: function render() { return _react2['default'].createElement(AntRadio, this.props); } }); AntRadio.Button = Button; exports['default'] = AntRadio; module.exports = exports['default']; /***/ }, /* 301 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(302); /***/ }, /* 302 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; 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; }; var React = __webpack_require__(76); var Checkbox = __webpack_require__(268); var Radio = React.createClass({ displayName: 'Radio', getDefaultProps: function getDefaultProps() { return { prefixCls: 'rc-radio', type: 'radio' }; }, render: function render() { return React.createElement(Checkbox, _extends({}, this.props, { ref: 'checkbox' })); } }); module.exports = Radio; /***/ }, /* 303 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _radio = __webpack_require__(300); var _radio2 = _interopRequireDefault(_radio); function getCheckedValue(children) { var checkedValue = null; _react2['default'].Children.forEach(children, function (radio) { if (radio.props && radio.props.checked) { checkedValue = radio.props.value; } }); return checkedValue; } exports['default'] = _react2['default'].createClass({ displayName: 'group', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-radio-group', onChange: function onChange() {} }; }, getInitialState: function getInitialState() { var props = this.props; return { value: props.value || props.defaultValue || getCheckedValue(props.children) }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('value' in nextProps || getCheckedValue(nextProps.children)) { this.setState({ value: nextProps.value || getCheckedValue(nextProps.children) }); } }, render: function render() { var _this = this; var props = this.props; var children = _react2['default'].Children.map(props.children, function (radio) { if (radio.props) { return _react2['default'].createElement(_radio2['default'], _extends({ key: radio.props.value }, radio.props, { onChange: _this.onRadioChange, checked: _this.state.value === radio.props.value })); } return radio; }); return _react2['default'].createElement( 'div', { className: props.prefixCls }, children ); }, onRadioChange: function onRadioChange(ev) { this.setState({ value: ev.target.value }); this.props.onChange(ev); } }); module.exports = exports['default']; /***/ }, /* 304 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcNotification = __webpack_require__(286); var _rcNotification2 = _interopRequireDefault(_rcNotification); var _objectAssign = __webpack_require__(184); var _objectAssign2 = _interopRequireDefault(_objectAssign); var top = 24; var notificationInstance = undefined; function getNotificationInstance() { if (notificationInstance) { return notificationInstance; } notificationInstance = _rcNotification2['default'].newInstance({ prefixCls: 'ant-notification', style: { top: top, right: 0 } }); return notificationInstance; } function notice(args) { var duration = undefined; if (args.duration === undefined) { duration = 4.5; } else { duration = args.duration; } if (args.icon) { var prefixCls = ' ant-notification-notice-content-icon-'; var iconClass = 'anticon anticon-'; switch (args.icon) { case 'success': iconClass += 'check-circle-o'; break; case 'info': iconClass += 'info-circle-o'; break; case 'error': iconClass += 'exclamation-circle-o'; break; case 'warn': iconClass += 'question-circle-o'; break; default: iconClass += 'info-circle'; } getNotificationInstance().notice({ content: _react2['default'].createElement( 'div', null, _react2['default'].createElement('i', { className: iconClass + prefixCls + 'icon-' + args.icon + prefixCls + 'icon' }), _react2['default'].createElement( 'p', { className: prefixCls + 'message' }, args.message ), _react2['default'].createElement( 'p', { className: prefixCls + 'description' }, args.description ) ), duration: duration, closable: true, onClose: args.onClose, style: {} }); } else { var prefixCls = 'ant-notification-notice-content-'; if (!args.btn) { getNotificationInstance().notice({ content: _react2['default'].createElement( 'div', null, _react2['default'].createElement( 'p', { className: prefixCls + 'message' }, args.message ), _react2['default'].createElement( 'p', { className: prefixCls + 'description' }, args.description ) ), duration: duration, closable: true, onClose: args.onClose, style: {} }); } else { getNotificationInstance().notice({ content: _react2['default'].createElement( 'div', null, _react2['default'].createElement( 'p', { className: prefixCls + 'message' }, args.message ), _react2['default'].createElement( 'p', { className: prefixCls + 'description' }, args.description ), _react2['default'].createElement( 'span', { className: prefixCls + 'btn' }, args.btn ) ), duration: duration, closable: true, onClose: args.onClose, key: args.key, style: {} }); } } } var api = { open: function open(args) { notice(args); }, close: function close(key) { if (notificationInstance) { notificationInstance.removeNotice(key); } }, config: function config(options) { top = isNaN(options.top) ? 24 : options.top; } }; ['success', 'info', 'warn', 'error'].forEach(function (type) { api[type] = function (args) { var newArgs = (0, _objectAssign2['default'])({}, args, { icon: type }); return api.open(newArgs); }; }); exports['default'] = api; module.exports = exports['default']; /***/ }, /* 305 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); exports['default'] = _react2['default'].createClass({ displayName: 'index', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-alert' }; }, getInitialState: function getInitialState() { return { closing: true, closed: false }; }, handleClose: function handleClose(e) { var dom = _react2['default'].findDOMNode(this); dom.style.height = dom.offsetHeight + 'px'; // Magic code // 重复一次后才能正确设置 height dom.style.height = dom.offsetHeight + 'px'; this.setState({ closing: false }); if (this.props.onClose) { this.props.onClose.call(this, e); } }, animationEnd: function animationEnd() { this.setState({ closed: true, closing: true }); }, render: function render() { var iconClass = this.props.description ? 'ant-alert-with-description-icon anticon-' : 'ant-alert-icon anticon-'; switch (this.props.type) { case 'success': iconClass += 'check-circle'; break; case 'info': iconClass += 'info-circle'; break; case 'error': iconClass += 'exclamation-circle'; break; case 'warn': iconClass += 'question-circle'; break; default: iconClass += 'default'; } var html = undefined; var closeName = !this.state.closing ? ' ' + this.props.prefixCls + '-close' : ''; if (this.props.description) { var _close = this.props.closable ? _react2['default'].createElement( 'a', { onClick: this.handleClose, className: 'ant-alert-with-description-close-icon' }, _react2['default'].createElement('span', { className: 'ant-alert-with-description-close-icon-x' }) ) : ''; html = _react2['default'].createElement( 'div', { 'data-show': this.state.closing, className: 'ant-alert-with-description ant-alert-with-description-' + this.props.type + closeName }, _react2['default'].createElement('i', { className: 'anticon ' + iconClass }), _react2['default'].createElement( 'p', { className: 'ant-alert-with-description-message' }, this.props.message ), _react2['default'].createElement( 'span', { className: 'ant-alert-with-description-description' }, this.props.description ), _close ); } else { if (this.props.closeText) { html = _react2['default'].createElement( 'div', { 'data-show': this.state.closing, className: 'ant-alert ant-alert-' + this.props.type + closeName }, _react2['default'].createElement('i', { className: 'anticon ' + iconClass }), _react2['default'].createElement( 'span', { className: 'ant-alert-description' }, this.props.message ), _react2['default'].createElement( 'span', { onClick: this.handleClose, className: 'ant-alert-close-text' }, this.props.closeText ) ); } else { var _close2 = this.props.closable ? _react2['default'].createElement( 'a', { onClick: this.handleClose, className: 'ant-alert-close-icon' }, _react2['default'].createElement('span', { className: 'ant-alert-close-icon-x' }) ) : ''; html = _react2['default'].createElement( 'div', { 'data-show': this.state.closing, className: 'ant-alert ant-alert-' + this.props.type + closeName }, _react2['default'].createElement('i', { className: 'anticon ' + iconClass }), _react2['default'].createElement( 'span', { className: 'ant-alert-description' }, this.props.message ), _close2 ); } } return this.state.closed ? null : _react2['default'].createElement( _rcAnimate2['default'], { component: '', showProp: 'data-show', transitionName: 'slide-up', onEnd: this.animationEnd }, html ); } }); module.exports = exports['default']; /***/ }, /* 306 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rcFormValidation = __webpack_require__(307); var _rcFormValidation2 = _interopRequireDefault(_rcFormValidation); exports['default'] = _rcFormValidation2['default']; module.exports = exports['default']; /***/ }, /* 307 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(308); /***/ }, /* 308 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _asyncValidator = __webpack_require__(309); var _asyncValidator2 = _interopRequireDefault(_asyncValidator); var _Validator = __webpack_require__(333); var _Validator2 = _interopRequireDefault(_Validator); var _objectAssign = __webpack_require__(184); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _FieldMixin = __webpack_require__(334); var _FieldMixin2 = _interopRequireDefault(_FieldMixin); var actionId = 0; var Validation = (function (_React$Component) { _inherits(Validation, _React$Component); function Validation(props) { var _this = this; _classCallCheck(this, Validation); _get(Object.getPrototypeOf(Validation.prototype), 'constructor', this).call(this, props); this.validators = {}; ['attachValidator', 'detachValidator', 'onInputChange', 'onInputChangeSilently'].forEach(function (m) { _this[m] = _this[m].bind(_this); }); } _createClass(Validation, [{ key: 'onInputChangeSilently', value: function onInputChangeSilently(validator, value) { var r = this.getValidateResult(); r.formData[validator.getName()] = value; this.props.onValidate(r.status, r.formData); } }, { key: 'onInputChange', value: function onInputChange(validator, v, fn) { var value = v; var name = validator.getName(); var schema = this.getSchema(validator); var rules = schema[name]; rules.forEach(function (rule, index) { if (rule.transform) { value = rule.transform(value); var newRule = (0, _objectAssign2['default'])({}, rule); newRule.transform = null; rules[index] = newRule; } }); var values = {}; values[name] = value; validator.errors = undefined; validator.isValidating = true; validator.dirty = true; var currentActionId = actionId; validator.actionId = currentActionId; actionId++; var result = this.getValidateResult(); result.formData[name] = value; this.props.onValidate(result.status, result.formData); var self = this; new _asyncValidator2['default'](schema).validate(values, function (errors) { var validators = self.validators; // in case component is unmount and remount var nowValidator = validators[name]; // prevent concurrency call if (nowValidator && nowValidator.actionId === currentActionId) { validator.errors = errors; validator.isValidating = false; validator.dirty = false; var r = self.getValidateResult(); r.formData[name] = value; self.props.onValidate(r.status, r.formData); if (fn) { fn(); } } }); } }, { key: 'getSchema', value: function getSchema(validator) { var ret = {}; var rules = validator.props.rules; if (Array.isArray(rules)) { rules = rules.concat(); } else { rules = [rules]; } ret[validator.getName()] = rules; return ret; } }, { key: 'getValidateResult', value: function getValidateResult() { var formData = {}; var status = {}; var validators = this.validators; Object.keys(validators).forEach(function (name) { var validator = validators[name]; var errors = undefined; if (validator.errors) { errors = validator.errors.map(function (e) { return e.message; }); } if (errors && errors.length === 0) { errors = null; } status[name] = { errors: errors, isValidating: validator.isValidating }; formData[name] = validator.getValue(); }); return { formData: formData, status: status }; } }, { key: 'render', value: function render() { return _react2['default'].createElement( 'div', { className: this.props.className }, this.attachValidators(this.props.children) ); } }, { key: 'isValid', value: function isValid() { var result = this.getValidateResult().status; return Object.keys(result).every(function (name) { if (result[name].isValidating || result[name].errors) { return false; } return true; }); } }, { key: 'attachValidators', value: function attachValidators(children) { var self = this; if (children) { var _ret = (function () { // refer: React traverseAllChildrenImpl // bug fix for react 0.13 @2015.07.02 // option should not have non-text children // <option>11</option> // React.Children.map(option.props.children,function(c){return c}) => {'.0':'11'} var type = typeof children; if (type === 'boolean') { return { v: children }; } if (type === 'string' || type === 'number') { return { v: children }; } var childrenArray = []; var ret = _react2['default'].Children.map(children, function (c) { var child = c; if (_react2['default'].isValidElement(child)) { if (child.type === _Validator2['default']) { child = _react2['default'].cloneElement(child, { attachValidator: self.attachValidator, detachValidator: self.detachValidator, onInputChange: self.onInputChange, onInputChangeSilently: self.onInputChangeSilently }); } else if (child.props) { child = _react2['default'].cloneElement(child, {}, self.attachValidators(child.props.children)); } } childrenArray.push(child); return child; }); // if only one child, then flatten if (childrenArray.length === 1) { return { v: childrenArray[0] }; } return { v: ret }; })(); if (typeof _ret === 'object') return _ret.v; } return children; } }, { key: 'attachValidator', value: function attachValidator(validator) { var name = validator.getName(); this.validators[name] = validator; } }, { key: 'detachValidator', value: function detachValidator(validator) { delete this.validators[validator.getName()]; } }, { key: 'forceValidate', value: function forceValidate(fs, callback) { var _this2 = this; var fields = fs; // must async to allow state sync setTimeout(function () { var self = _this2; var validators = _this2.validators; var validator = undefined; var doing = 0; fields = fields || Object.keys(validators); var count = fields.length; if (count === 0) { callback(self.isValid()); return; } function track() { doing++; if (doing === count) { if (callback) { callback(self.isValid()); } } } fields.forEach(function (name) { validator = validators[name]; self.onInputChange(validator, validator.getValue(), track); }); }, 0); } }, { key: 'validate', value: function validate(callback) { var _this3 = this; var self = this; var validators = this.validators; var count = 0; var validator = undefined; var doing = 0; Object.keys(validators).forEach(function (name) { validator = validators[name]; if (validator.dirty) { count++; } }); if (count === 0) { callback(self.isValid()); return; } function track() { doing++; if (doing === count) { callback(self.isValid()); } } Object.keys(validators).forEach(function (name) { validator = validators[name]; if (validator.dirty) { _this3.onInputChange(validator, validator.getValue(), track); } }); } }, { key: 'reset', value: function reset() { var validators = this.validators; Object.keys(validators).forEach(function (name) { validators[name].reset(); }); } }]); return Validation; })(_react2['default'].Component); Validation.propTypes = { onChange: _react2['default'].PropTypes.func, onValidate: _react2['default'].PropTypes.func, className: _react2['default'].PropTypes.string, children: _react2['default'].PropTypes.any }; Validation.defaultProps = { onValidate: function onValidate() {} }; Validation.Validator = _Validator2['default']; Validation.FieldMixin = _FieldMixin2['default']; exports['default'] = Validation; module.exports = exports['default']; /***/ }, /* 309 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); var _validator = __webpack_require__(311); var _validator2 = _interopRequireDefault(_validator); var _messages2 = __webpack_require__(332); var _messages3 = _interopRequireDefault(_messages2); var _rule = __webpack_require__(313); function asyncMap(arr, func, callback) { var results = []; function count(_, result) { results.push(result); if (results.length === arr.length) { callback(null, results); } } arr.forEach(function (a) { func(a, count); }); } function complementError(rule) { return function (oe) { var e = oe; if (!e.message) { e = new Error(e); } e.field = e.field || rule.fullField; return e; }; } /** * Encapsulates a validation schema. * * @param descriptor An object declaring validation rules * for this schema. */ function Schema(descriptor) { this.rules = null; this._messages = _messages3['default']; this.define(descriptor); } Schema.prototype = { messages: function messages(_messages) { if (_messages) { this._messages = _messages; } return this._messages; }, define: function define(rules) { if (!rules) { throw new Error('Cannot configure a schema with no rules'); } if (typeof rules !== 'object' || Array.isArray(rules)) { throw new Error('Rules must be an object'); } this.rules = {}; var z = undefined; var item = undefined; for (z in rules) { if (rules.hasOwnProperty(z)) { item = rules[z]; this.rules[z] = Array.isArray(item) ? item : [item]; } } }, validate: function validate(source, o, oc) { var _this = this; if (!this.rules) { throw new Error('Cannot validate with no rules.'); } var callback = oc; var options = o || {}; if (typeof options === 'function') { callback = options; options = {}; } function complete(results) { var i = undefined; var field = undefined; var errors = []; var fields = {}; function add(e) { if (e instanceof Error) { errors.push(e); } else if (Array.isArray(e)) { errors = errors.concat.apply(errors, e); } } for (i = 0; i < results.length; i++) { add(results[i]); } if (!errors.length) { errors = null; fields = null; } else { if (options.single) { errors = errors.slice(0, 1); } for (i = 0; i < errors.length; i++) { field = errors[i].field; fields[field] = fields[field] || []; fields[field].push(errors[i]); } } callback(errors, fields); } options.messages = options.messages || this.messages(); options.error = _rule.error; var arr = undefined; var value = undefined; var series = []; var keys = options.keys || Object.keys(this.rules); keys.forEach(function (z) { arr = _this.rules[z]; value = source[z]; arr.forEach(function (r) { var rule = r; if (typeof rule.transform === 'function') { value = source[z] = rule.transform(value); } if (typeof rule === 'function') { rule = { validator: rule }; } rule.field = z; rule.fullField = rule.fullField || z; rule.type = _this.getType(rule); rule.validator = _this.getValidationMethod(rule); if (!rule.validator) { return; } series.push({ rule: rule, value: value, source: source, field: z }); }); }); asyncMap(series, function (data, doIt) { var rule = data.rule; var deep = (rule.type === 'object' || rule.type === 'array') && typeof rule.fields === 'object'; deep = deep && (rule.required || !rule.required && data.value); rule.field = data.field; function cb(e) { var errors = e; if (errors && !Array.isArray(errors)) { errors = [errors]; } if (errors && errors.length && rule.message) { errors = [].concat(rule.message); } if (errors) { errors = errors.map(complementError(rule)); } if (options.first && errors && errors.length) { return doIt(errors); } if (!deep) { doIt(null, errors); } else { errors = errors || []; // if rule is required but the target object // does not exist fail at the rule level and don't // go deeper if (rule.required && !data.value) { if (rule.message) { errors = [].concat(rule.message).map(complementError(rule)); } else { errors = [options.error(rule, _util2['default'].format(options.messages.required, rule.field))]; } return doIt(null, errors); } var fieldsSchema = data.rule.fields; for (var f in fieldsSchema) { if (fieldsSchema.hasOwnProperty(f)) { var fieldSchema = fieldsSchema[f]; fieldSchema.fullField = rule.fullField + '.' + f; } } var schema = new Schema(fieldsSchema); schema.messages(options.messages); if (data.rule.options) { data.rule.options.messages = options.messages; data.rule.options.error = options.error; } schema.validate(data.value, data.rule.options || options, function (errs) { doIt(null, errs && errs.length ? errors.concat(errs) : errs); }); } } rule.validator(rule, data.value, cb, data.source, options); }, function (err, results) { complete(results); }); }, getType: function getType(rule) { if (rule.type === undefined && rule.pattern instanceof RegExp) { rule.type = 'pattern'; } if (typeof rule.validator !== 'function' && (rule.type && !_validator2['default'].hasOwnProperty(rule.type))) { throw new Error(_util2['default'].format('Unknown rule type %s', rule.type)); } return rule.type || 'string'; }, getValidationMethod: function getValidationMethod(rule) { if (typeof rule.validator === 'function') { return rule.validator; } return _validator2['default'][rule.type] || false; } }; Schema.register = function register(type, validator) { if (typeof validator !== 'function') { throw new Error('Cannot register a validator by type, validator is not a function'); } _validator2['default'][type] = validator; }; Schema.messages = _messages3['default']; exports['default'] = Schema; module.exports = exports['default']; /***/ }, /* 310 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var formatRegExp = /%[sdj%]/g; exports['default'] = { format: function format() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var i = 1; var f = args[0]; var len = args.length; var str = String(f).replace(formatRegExp, function (x) { if (x === '%%') { return '%'; } if (i >= len) { return x; } switch (x) { case '%s': return String(args[i++]); case '%d': return Number(args[i++]); case '%j': try { return JSON.stringify(args[i++]); } catch (_) { return '[Circular]'; } break; default: return x; } }); for (var arg = args[i]; i < len; arg = args[++i]) { str += ' ' + arg; } return str; }, isEmptyValue: function isEmptyValue(value, type) { if (value === undefined || value === null) { return true; } if (type === 'array' && Array.isArray(value) && !value.length) { return true; } if (type === 'string' && typeof value === 'string' && !value) { return true; } return false; } }; module.exports = exports['default']; /***/ }, /* 311 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports['default'] = { string: __webpack_require__(312), method: __webpack_require__(320), number: __webpack_require__(321), boolean: __webpack_require__(322), regexp: __webpack_require__(323), integer: __webpack_require__(324), 'float': __webpack_require__(325), array: __webpack_require__(326), object: __webpack_require__(327), 'enum': __webpack_require__(328), pattern: __webpack_require__(329), email: __webpack_require__(330), url: __webpack_require__(330), date: __webpack_require__(331), hex: __webpack_require__(330) }; module.exports = exports['default']; /***/ }, /* 312 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); /** * Performs validation for string types. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function string(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (_util2['default'].isEmptyValue(value, 'string') && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options, 'string'); if (!_util2['default'].isEmptyValue(value, 'string')) { _rule2['default'].type(rule, value, source, errors, options); _rule2['default'].range(rule, value, source, errors, options); _rule2['default'].pattern(rule, value, source, errors, options); if (rule.whitespace === true) { _rule2['default'].whitespace(rule, value, source, errors, options); } } } callback(errors); } exports['default'] = string; module.exports = exports['default']; /***/ }, /* 313 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports['default'] = { required: __webpack_require__(314), whitespace: __webpack_require__(315), type: __webpack_require__(316), range: __webpack_require__(317), 'enum': __webpack_require__(318), pattern: __webpack_require__(319) }; module.exports = exports['default']; /***/ }, /* 314 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); /** * Rule for validating required fields. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function required(rule, value, source, errors, options, type) { if (rule.required && (!source.hasOwnProperty(rule.field) || _util2['default'].isEmptyValue(value, type))) { errors.push(_util2['default'].format(options.messages.required, rule.fullField)); } } exports['default'] = required; module.exports = exports['default']; /***/ }, /* 315 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); /** * Rule for validating whitespace. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function whitespace(rule, value, source, errors, options) { if (/^\s+$/.test(value) || value === '') { errors.push(_util2['default'].format(options.messages.whitespace, rule.fullField)); } } exports['default'] = whitespace; module.exports = exports['default']; /***/ }, /* 316 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); var _required = __webpack_require__(314); var _required2 = _interopRequireDefault(_required); var pattern = { email: /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/, url: /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/, hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i }; var types = { integer: function integer(value) { return types.number(value) && parseInt(value, 10) === value; }, float: function float(value) { return types.number(value) && !types.integer(value); }, array: function array(value) { return Array.isArray(value); }, regexp: function regexp(value) { if (value instanceof RegExp) { return true; } try { return !!new RegExp(value); } catch (e) { return false; } }, date: function date(value) { return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function'; }, number: function number(value) { if (isNaN(value)) { return false; } return typeof value === 'number'; }, object: function object(value) { return typeof value === 'object' && !types.array(value); }, method: function method(value) { return typeof value === 'function'; }, email: function email(value) { return typeof value === 'string' && !!value.match(pattern.email); }, url: function url(value) { return typeof value === 'string' && !!value.match(pattern.url); }, hex: function hex(value) { return typeof value === 'string' && !!value.match(pattern.hex); } }; /** * Rule for validating the type of a value. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function type(rule, value, source, errors, options) { if (rule.required && value === undefined) { (0, _required2['default'])(rule, value, source, errors, options); return; } var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date']; var ruleType = rule.type; if (custom.indexOf(ruleType) > -1) { if (!types[ruleType](value)) { errors.push(_util2['default'].format(options.messages.types[ruleType], rule.fullField, rule.type)); } // straight typeof check } else if (ruleType && typeof value !== rule.type) { errors.push(_util2['default'].format(options.messages.types[ruleType], rule.fullField, rule.type)); } } exports['default'] = type; module.exports = exports['default']; /***/ }, /* 317 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); /** * Rule for validating minimum and maximum allowed values. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function range(rule, value, source, errors, options) { var len = typeof rule.len === 'number'; var min = typeof rule.min === 'number'; var max = typeof rule.max === 'number'; var val = value; var key = null; var num = typeof value === 'number'; var str = typeof value === 'string'; var arr = Array.isArray(value); if (num) { key = 'number'; } else if (str) { key = 'string'; } else if (arr) { key = 'array'; } // if the value is not of a supported type for range validation // the validation rule rule should use the // type property to also test for a particular type if (!key) { return false; } if (str || arr) { val = value.length; } if (len) { if (val !== rule.len) { errors.push(_util2['default'].format(options.messages[key].len, rule.fullField, rule.len)); } } else if (min && !max && val < rule.min) { errors.push(_util2['default'].format(options.messages[key].min, rule.fullField, rule.min)); } else if (max && !min && val > rule.max) { errors.push(_util2['default'].format(options.messages[key].max, rule.fullField, rule.max)); } else if (min && max && (val < rule.min || val > rule.max)) { errors.push(_util2['default'].format(options.messages[key].range, rule.fullField, rule.min, rule.max)); } } exports['default'] = range; module.exports = exports['default']; /***/ }, /* 318 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); var ENUM = 'enum'; /** * Rule for validating a value exists in an enumerable list. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function enumerable(rule, value, source, errors, options) { rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : []; if (rule[ENUM].indexOf(value) === -1) { errors.push(_util2['default'].format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', '))); } } exports['default'] = enumerable; module.exports = exports['default']; /***/ }, /* 319 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); /** * Rule for validating a regular expression pattern. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function pattern(rule, value, source, errors, options) { if (rule.pattern instanceof RegExp) { if (!rule.pattern.test(value)) { errors.push(_util2['default'].format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern)); } } } exports['default'] = pattern; module.exports = exports['default']; /***/ }, /* 320 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); /** * Validates a function. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function method(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value !== undefined) { _rule2['default'].type(rule, value, source, errors, options); } } callback(errors); } exports['default'] = method; module.exports = exports['default']; /***/ }, /* 321 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); /** * Validates a number. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function number(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value !== undefined) { _rule2['default'].type(rule, value, source, errors, options); _rule2['default'].range(rule, value, source, errors, options); } } callback(errors); } exports['default'] = number; module.exports = exports['default']; /***/ }, /* 322 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); /** * Validates a boolean. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function boolean(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value !== undefined) { _rule2['default'].type(rule, value, source, errors, options); } } callback(errors); } exports['default'] = boolean; module.exports = exports['default']; /***/ }, /* 323 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); /** * Validates the regular expression type. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function regexp(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value !== undefined) { _rule2['default'].type(rule, value, source, errors, options); } } callback(errors); } exports['default'] = regexp; module.exports = exports['default']; /***/ }, /* 324 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); /** * Validates a number is an integer. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function integer(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value !== undefined) { _rule2['default'].type(rule, value, source, errors, options); _rule2['default'].range(rule, value, source, errors, options); } } callback(errors); } exports['default'] = integer; module.exports = exports['default']; /***/ }, /* 325 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); /** * Validates a number is a floating point number. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function floatFn(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value !== undefined) { _rule2['default'].type(rule, value, source, errors, options); _rule2['default'].range(rule, value, source, errors, options); } } callback(errors); } exports['default'] = floatFn; module.exports = exports['default']; /***/ }, /* 326 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); /** * Validates an array. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function array(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (_util2['default'].isEmptyValue(value, 'array') && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options, 'array'); if (!_util2['default'].isEmptyValue(value, 'array')) { _rule2['default'].type(rule, value, source, errors, options); _rule2['default'].range(rule, value, source, errors, options); } } callback(errors); } exports['default'] = array; module.exports = exports['default']; /***/ }, /* 327 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); /** * Validates an object. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function object(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value !== undefined) { _rule2['default'].type(rule, value, source, errors, options); } } callback(errors); } exports['default'] = object; module.exports = exports['default']; /***/ }, /* 328 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); var ENUM = 'enum'; /** * Validates an enumerable list. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function enumerable(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value) { _rule2['default'][ENUM](rule, value, source, errors, options); } } callback(errors); } exports['default'] = enumerable; module.exports = exports['default']; /***/ }, /* 329 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); var _util = __webpack_require__(310); var _util2 = _interopRequireDefault(_util); /** * Validates a regular expression pattern. * * Performs validation when a rule only contains * a pattern property but is not declared as a string type. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function pattern(rule, value, callback, source, options) { var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); if (validate) { if (_util2['default'].isEmptyValue(value, 'string') && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (!_util2['default'].isEmptyValue(value, 'string')) { _rule2['default'].pattern(rule, value, source, errors, options); } } callback(errors); } exports['default'] = pattern; module.exports = exports['default']; /***/ }, /* 330 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); function type(rule, value, callback, source, options) { var errors = []; _rule2['default'].type(rule, value, source, errors, options); callback(errors); } exports['default'] = type; module.exports = exports['default']; /***/ }, /* 331 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _rule = __webpack_require__(313); var _rule2 = _interopRequireDefault(_rule); function date(rule, value, callback, source, options) { // console.log('integer rule called %j', rule); var errors = []; var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); // console.log('validate on %s value', value); if (validate) { if (value === undefined && !rule.required) { return callback(); } _rule2['default'].required(rule, value, source, errors, options); if (value) { _rule2['default'].type(rule, value, source, errors, options); _rule2['default'].range(rule, value.getTime(), source, errors, options); } } callback(errors); } exports['default'] = date; module.exports = exports['default']; /***/ }, /* 332 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var messages = { 'default': 'Validation error on field %s', required: '%s is required', 'enum': '%s must be one of %s', whitespace: '%s cannot be empty', date: { format: '%s date %s is invalid for format %s', parse: '%s date could not be parsed, %s is invalid ', invalid: '%s date %s is invalid' }, types: { string: '%s is not a %s', method: '%s is not a %s (function)', array: '%s is not an %s', object: '%s is not an %s', number: '%s is not a %s', boolean: '%s is not a %s', integer: '%s is not an %s', float: '%s is not a %s', regexp: '%s is not a valid %s', email: '%s is not a valid %s', url: '%s is not a valid %s', hex: '%s is not a valid %s' }, string: { len: '%s must be exactly %s characters', min: '%s must be at least %s characters', max: '%s cannot be longer than %s characters', range: '%s must be between %s and %s characters' }, number: { len: '%s must equal %s', min: '%s cannot be less than %s', max: '%s cannot be greater than %s', range: '%s must be between %s and %s' }, array: { len: '%s must be exactly %s in length', min: '%s cannot be less than %s in length', max: '%s cannot be greater than %s in length', range: '%s must be between %s and %s in length' }, pattern: { mismatch: '%s value %s does not match pattern %s' }, clone: function clone() { var cloned = JSON.parse(JSON.stringify(this)); cloned.clone = this.clone; return cloned; } }; exports['default'] = messages; module.exports = exports['default']; /***/ }, /* 333 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); function getValueFromEvent(e) { // support custom element return e.target ? e.target.value : e; } function hasPlaceholder(child) { return child.type === 'input' && !!child.props.placeholder; } function ieGT9() { if (typeof document === undefined) { return false; } var documentMode = document.documentMode || 0; return documentMode > 9; } var Validator = (function (_React$Component) { _inherits(Validator, _React$Component); function Validator(props) { _classCallCheck(this, Validator); _get(Object.getPrototypeOf(Validator.prototype), 'constructor', this).call(this, props); this.reset(); this.onChange = this.onChange.bind(this); this.onChangeSilently = this.onChangeSilently.bind(this); } _createClass(Validator, [{ key: 'reset', value: function reset() { this.errors = undefined; this.dirty = true; this.isValidating = false; // in case component is unmount and remount this.actionId = -1; } }, { key: 'getInputElement', value: function getInputElement() { return _react2['default'].Children.only(this.props.children); } }, { key: 'onChange', value: function onChange(e) { this.props.onInputChange(this, getValueFromEvent(e)); } }, { key: 'onChangeSilently', value: function onChangeSilently(e) { // keep last error this.dirty = true; this.isValidating = false; this.props.onInputChangeSilently(this, getValueFromEvent(e)); } }, { key: 'getName', value: function getName() { return this.getInputElement().props.name; } }, { key: 'getValue', value: function getValue() { return this.getInputElement().props.value; } }, { key: 'render', value: function render() { var props = this.props; var child = this.getInputElement(); var trigger = props.trigger; var extraProps = {}; // keep model updated if (trigger !== 'onChange') { extraProps.onChange = (0, _rcUtil.createChainedFunction)(child.props.onChange, this.onChangeSilently); } extraProps[trigger] = (0, _rcUtil.createChainedFunction)(child.props[trigger], this.onChange); if (hasPlaceholder(child) && ieGT9()) { // https://github.com/react-component/form-validation/issues/13 extraProps.placeholder = undefined; } return _react2['default'].cloneElement(child, extraProps); } }, { key: 'componentDidMount', value: function componentDidMount() { this.props.attachValidator(this); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { this.props.attachValidator(this); } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.props.detachValidator(this); } }]); return Validator; })(_react2['default'].Component); Validator.defaultProps = { trigger: 'onChange' }; Validator.propTypes = { attachValidator: _react2['default'].PropTypes.func, detachValidator: _react2['default'].PropTypes.func, onInputChange: _react2['default'].PropTypes.func, onInputChangeSilently: _react2['default'].PropTypes.func, trigger: _react2['default'].PropTypes.string }; exports['default'] = Validator; module.exports = exports['default']; /***/ }, /* 334 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function merge() { var ret = {}; var args = [].slice.call(arguments, 0); args.forEach(function (a) { Object.keys(a).forEach(function (k) { ret[k] = a[k]; }); }); return ret; } var FieldMixin = { setField: function setField(field, e) { var v = e; var target = e && e.target; if (target) { // no radio if ((target.nodeName + '').toLowerCase() === 'input' && target.type === 'checkbox') { v = target.checked; } else { v = e.target.value; } } var newFormData = {}; newFormData[field] = v; this.setState({ formData: merge(this.state.formData, newFormData) }); }, handleValidate: function handleValidate(status, formData) { this.onValidate(status, formData); }, onValidate: function onValidate(status, formData) { this.setState({ status: merge(this.state.status, status), formData: merge(this.state.formData, formData) }); } }; exports['default'] = FieldMixin; module.exports = exports['default']; /***/ }, /* 335 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcTree = __webpack_require__(336); var _rcTree2 = _interopRequireDefault(_rcTree); var _commonOpenAnimation = __webpack_require__(340); var _commonOpenAnimation2 = _interopRequireDefault(_commonOpenAnimation); var AntTree = _react2['default'].createClass({ displayName: 'AntTree', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-tree', checkable: false, showIcon: false }; }, render: function render() { var props = this.props; var checkable = props.checkable; if (checkable) { checkable = _react2['default'].createElement('span', { className: props.prefixCls + '-checkbox-inner' }); } return _react2['default'].createElement( _rcTree2['default'], _extends({ openAnimation: _commonOpenAnimation2['default'] }, props, { checkable: checkable }), this.props.children ); } }); AntTree.TreeNode = _rcTree2['default'].TreeNode; exports['default'] = AntTree; module.exports = exports['default']; /***/ }, /* 336 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _Tree = __webpack_require__(337); var _Tree2 = _interopRequireDefault(_Tree); var _TreeNode = __webpack_require__(338); var _TreeNode2 = _interopRequireDefault(_TreeNode); _Tree2['default'].TreeNode = _TreeNode2['default']; exports['default'] = _Tree2['default']; module.exports = exports['default']; /***/ }, /* 337 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; 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 { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); // sorted array ['0-0','0-1', '0-0-1', '0-1-1'] => ['0-0', '0-1'] var filterMin = function filterMin(arr) { var a = []; arr.forEach(function (item) { var b = a.filter(function (i) { return item.indexOf(i) === 0; }); if (!b.length) { a.push(item); } }); return a; }; var Tree = (function (_React$Component) { _inherits(Tree, _React$Component); function Tree(props) { var _this = this; _classCallCheck(this, Tree); _get(Object.getPrototypeOf(Tree.prototype), 'constructor', this).call(this, props); ['handleKeyDown', 'handleCheck'].forEach(function (m) { _this[m] = _this[m].bind(_this); }); var expandedKeys = props.defaultExpandedKeys; var checkedKeys = props.defaultCheckedKeys; this.defaultExpandAll = props.defaultExpandAll; var selectedKeys = props.multiple ? [].concat(_toConsumableArray(props.defaultSelectedKeys)) : [props.defaultSelectedKeys[0]]; this.state = { expandedKeys: expandedKeys, checkedKeys: checkedKeys, selectedKeys: selectedKeys }; } _createClass(Tree, [{ key: 'getCheckKeys', value: function getCheckKeys() { var _this2 = this; var checkPartKeys = []; var checkedKeys = []; Object.keys(this.treeNodesChkStates).forEach(function (item) { var itemObj = _this2.treeNodesChkStates[item]; if (itemObj.checked) { checkedKeys.push(itemObj.key); } else if (itemObj.checkPart) { checkPartKeys.push(itemObj.key); } }); return { checkPartKeys: checkPartKeys, checkedKeys: checkedKeys }; } }, { key: 'getOpenTransitionName', value: function getOpenTransitionName() { var props = this.props; var transitionName = props.openTransitionName; var animationName = props.openAnimation; if (!transitionName && typeof animationName === 'string') { transitionName = props.prefixCls + '-open-' + animationName; } return transitionName; } }, { key: 'renderTreeNode', value: function renderTreeNode(child, index) { var level = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2]; var key = child.key || level + '-' + index; var state = this.state; var props = this.props; var cloneProps = { ref: 'treeNode', root: this, eventKey: key, pos: level + '-' + index, prefixCls: props.prefixCls, showLine: props.showLine, showIcon: props.showIcon, checkable: props.checkable, expanded: this.defaultExpandAll || state.expandedKeys.indexOf(key) !== -1, selected: state.selectedKeys.indexOf(key) !== -1, checked: this.checkedKeys.indexOf(key) !== -1, checkPart: this.checkPartKeys.indexOf(key) !== -1, openTransitionName: this.getOpenTransitionName(), openAnimation: props.openAnimation }; return _react2['default'].cloneElement(child, cloneProps); } }, { key: 'render', value: function render() { var _this3 = this; var props = this.props; var domProps = { className: (0, _rcUtil.classSet)(props.className, props.prefixCls), role: 'tree-node' }; if (props.focusable) { domProps.tabIndex = '0'; domProps.onKeyDown = this.handleKeyDown; } var checkedKeys = this.state.checkedKeys; var checkedPos = []; this.treeNodesChkStates = {}; this.loopAllChildren(props.children, function (item, index, pos) { var key = item.key || pos; var checked = false; if (checkedKeys.indexOf(key) !== -1) { checked = true; checkedPos.push(pos); } _this3.treeNodesChkStates[pos] = { key: key, checked: checked, checkPart: false }; }); this.handleCheckState(this.treeNodesChkStates, filterMin(checkedPos.sort())); var checkKeys = this.getCheckKeys(); this.checkPartKeys = checkKeys.checkPartKeys; this.checkedKeys = checkKeys.checkedKeys; this.newChildren = _react2['default'].Children.map(props.children, this.renderTreeNode, this); return _react2['default'].createElement( 'ul', _extends({}, domProps, { ref: 'tree' }), this.newChildren ); } }, { key: 'loopAllChildren', value: function loopAllChildren(childs, callback) { var loop = function loop(children, level) { _react2['default'].Children.forEach(children, function (item, index) { var pos = level + '-' + index; var newChildren = item.props.children; if (Array.isArray(newChildren)) { loop(newChildren, pos); } callback(item, index, pos); }); }; loop(childs, 0); } }, { key: 'handleCheckState', value: function handleCheckState(obj, checkedArr, unCheckEvent) { var evt = false; if (typeof unCheckEvent === 'boolean') { evt = true; } checkedArr.forEach(function (_pos) { Object.keys(obj).forEach(function (i) { if (i.length > _pos.length && i.indexOf(_pos) === 0) { obj[i].checkPart = false; if (evt) { if (unCheckEvent) { obj[i].checked = false; } else { obj[i].checked = true; } } else { obj[i].checked = true; } } }); var loop = function loop(__pos) { var _posLen = __pos.length; if (_posLen <= 3) { return; } var sibling = 0; var siblingChecked = 0; var parentPos = __pos.substring(0, _posLen - 2); Object.keys(obj).forEach(function (i) { if (i.length === _posLen && i.substring(0, _posLen - 2) === parentPos) { sibling++; if (obj[i].checked) { siblingChecked++; } else if (obj[i].checkPart) { siblingChecked += 0.5; } } }); var parent = obj[parentPos]; // sibling 不会等于0 // 全不选 - 全选 - 半选 if (siblingChecked === 0) { parent.checked = false; parent.checkPart = false; } else if (siblingChecked === sibling) { parent.checked = true; parent.checkPart = false; } else { parent.checkPart = true; parent.checked = false; } loop(parentPos); }; loop(_pos); }); } }, { key: 'handleCheck', value: function handleCheck(treeNode) { var _this4 = this; var tnProps = treeNode.props; var checked = !tnProps.checked; if (tnProps.checkPart) { checked = true; } var pos = undefined; Object.keys(this.treeNodesChkStates).forEach(function (item) { var itemObj = _this4.treeNodesChkStates[item]; if (itemObj.key === (treeNode.key || tnProps.eventKey)) { pos = item; itemObj.checked = checked; itemObj.checkPart = false; } }); this.handleCheckState(this.treeNodesChkStates, [pos], !checked); var checkKeys = this.getCheckKeys(); this.checkPartKeys = checkKeys.checkPartKeys; this.setState({ checkedKeys: checkKeys.checkedKeys }); if (this.props.onCheck) { this.props.onCheck({ event: 'check', checked: checked, node: treeNode, checkedKeys: checkKeys.checkedKeys }); } } }, { key: 'handleSelect', value: function handleSelect(treeNode) { var props = this.props; var selectedKeys = [].concat(_toConsumableArray(this.state.selectedKeys)); var eventKey = treeNode.props.eventKey; var index = selectedKeys.indexOf(eventKey); var selected = undefined; if (index !== -1) { selected = false; selectedKeys.splice(index, 1); } else { selected = true; if (!props.multiple) { selectedKeys.length = 0; } selectedKeys.push(eventKey); } this.setState({ selectedKeys: selectedKeys }); if (props.onSelect) { props.onSelect({ event: 'select', selected: selected, node: treeNode, selectedKeys: selectedKeys }); } } }, { key: 'handleExpand', value: function handleExpand(treeNode) { var thisProps = this.props; var tnProps = treeNode.props; var expandedKeys = this.state.expandedKeys.concat([]); var expanded = !tnProps.expanded; if (this.defaultExpandAll) { this.loopAllChildren(thisProps.children, function (item, index, pos) { var key = item.key || pos; if (expandedKeys.indexOf(key) === -1) { expandedKeys.push(key); } }); this.defaultExpandAll = false; } var index = expandedKeys.indexOf(tnProps.eventKey); if (expanded) { if (index === -1) { expandedKeys.push(tnProps.eventKey); } } else { expandedKeys.splice(index, 1); } this.setState({ expandedKeys: expandedKeys }); } // all keyboard events callbacks run from here at first }, { key: 'handleKeyDown', value: function handleKeyDown(e) { e.preventDefault(); } }]); return Tree; })(_react2['default'].Component); Tree.propTypes = { prefixCls: _react2['default'].PropTypes.string, checkable: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.bool, _react2['default'].PropTypes.node]), showLine: _react2['default'].PropTypes.bool, showIcon: _react2['default'].PropTypes.bool, defaultExpandAll: _react2['default'].PropTypes.bool, defaultExpandedKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), defaultCheckedKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), defaultSelectedKeys: _react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), onCheck: _react2['default'].PropTypes.func, onSelect: _react2['default'].PropTypes.func, openTransitionName: _react2['default'].PropTypes.string, openAnimation: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.string, _react2['default'].PropTypes.object]) }; Tree.defaultProps = { prefixCls: 'rc-tree', multiple: false, checkable: false, showLine: false, showIcon: true, defaultExpandAll: false, defaultExpandedKeys: [], defaultCheckedKeys: [], defaultSelectedKeys: [] }; exports['default'] = Tree; module.exports = exports['default']; /***/ }, /* 338 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUtil = __webpack_require__(77); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var _objectAssign = __webpack_require__(339); var _objectAssign2 = _interopRequireDefault(_objectAssign); var defaultTitle = '---'; var TreeNode = (function (_React$Component) { _inherits(TreeNode, _React$Component); function TreeNode(props) { var _this = this; _classCallCheck(this, TreeNode); _get(Object.getPrototypeOf(TreeNode.prototype), 'constructor', this).call(this, props); ['handleExpand', 'handleCheck'].forEach(function (m) { _this[m] = _this[m].bind(_this); }); } _createClass(TreeNode, [{ key: 'getPosition', value: function getPosition(pos) { var obj = { last: false, center: false }; var siblings = Object.keys(this.props.root.treeNodesChkStates).filter(function (item) { var len = pos.length; return len === item.length && pos.substring(0, len - 2) === item.substring(0, len - 2); }); var sLen = siblings.length; var posIndex = Number(pos.substr(-1, 1)); if (sLen === 1 || posIndex === sLen - 1) { obj.last = true; } else { obj.center = true; } return obj; } }, { key: 'renderSwitcher', value: function renderSwitcher(props, expandedState) { var prefixCls = props.prefixCls; var switcherCls = _defineProperty({}, prefixCls + '-switcher', true); if (props.disabled) { switcherCls[prefixCls + '-switcher-disabled'] = true; return _react2['default'].createElement('span', { className: (0, _rcUtil.classSet)(switcherCls) }); } var posObj = this.getPosition(props.pos); if (!props.showLine) { switcherCls[prefixCls + '-noline_' + expandedState] = true; } else if (props.pos === '0-0') { switcherCls[prefixCls + '-roots_' + expandedState] = true; } else { switcherCls[prefixCls + '-center_' + expandedState] = posObj.center; switcherCls[prefixCls + '-bottom_' + expandedState] = posObj.last; } return _react2['default'].createElement('span', { className: (0, _rcUtil.classSet)(switcherCls), onClick: this.handleExpand }); } }, { key: 'renderCheckbox', value: function renderCheckbox(props) { var prefixCls = props.prefixCls; var checkboxCls = _defineProperty({}, prefixCls + '-checkbox', true); if (props.checkPart) { checkboxCls[prefixCls + '-checkbox-indeterminate'] = true; } else if (props.checked) { checkboxCls[prefixCls + '-checkbox-checked'] = true; } var customEle = null; if (typeof props.checkable !== 'boolean') { customEle = props.checkable; } if (props.disabled) { checkboxCls[prefixCls + '-checkbox-disabled'] = true; return _react2['default'].createElement( 'span', { ref: 'checkbox', className: (0, _rcUtil.classSet)(checkboxCls) }, customEle ); } return _react2['default'].createElement( 'span', { ref: 'checkbox', className: (0, _rcUtil.classSet)(checkboxCls), onClick: this.handleCheck }, customEle ); } }, { key: 'renderChildren', value: function renderChildren(props) { var renderFirst = this.renderFirst; this.renderFirst = 1; var transitionAppear = true; if (!renderFirst && props.expanded) { transitionAppear = false; } var children = props.children; var newChildren = children; if (!children) { return children; } if (children.type === TreeNode || Array.isArray(children) && children.every(function (item) { return item.type === TreeNode; })) { var _cls; var cls = (_cls = {}, _defineProperty(_cls, props.prefixCls + '-child-tree', true), _defineProperty(_cls, props.prefixCls + '-child-tree-open', props.expanded), _cls); if (props.showLine) { cls[props.prefixCls + '-line'] = this.getPosition(props.pos).center; } var animProps = {}; if (props.openTransitionName) { animProps.transitionName = props.openTransitionName; } else if (typeof props.openAnimation === 'object') { animProps.animation = (0, _objectAssign2['default'])({}, props.openAnimation); if (!transitionAppear) { delete animProps.animation.appear; } } newChildren = this.newChildren = _react2['default'].createElement( _rcAnimate2['default'], _extends({}, animProps, { showProp: 'expanded', transitionAppear: transitionAppear, component: '' }), _react2['default'].createElement( 'ul', { className: (0, _rcUtil.classSet)(cls), expanded: props.expanded }, _react2['default'].Children.map(children, function (item, index) { return props.root.renderTreeNode(item, index, props.pos); }, props.root) ) ); } return newChildren; } }, { key: 'render', value: function render() { var _iconEleCls, _this2 = this; var props = this.props; var prefixCls = props.prefixCls; var expandedState = props.expanded ? 'open' : 'close'; var iconEleCls = (_iconEleCls = {}, _defineProperty(_iconEleCls, prefixCls + '-iconEle', true), _defineProperty(_iconEleCls, prefixCls + '-icon__' + expandedState, true), _iconEleCls); var canRenderSwitcher = true; // let content = props.title; var content = props.title; var newChildren = this.renderChildren(props); if (!newChildren || newChildren === props.children) { // content = newChildren; newChildren = null; canRenderSwitcher = false; } var selectHandle = function selectHandle() { var icon = props.showIcon ? _react2['default'].createElement('span', { className: (0, _rcUtil.classSet)(iconEleCls) }) : null; var title = _react2['default'].createElement( 'span', { className: prefixCls + '-title' }, content ); var domProps = {}; if (!props.disabled) { if (props.selected) { domProps.className = prefixCls + '-node-selected'; } domProps.onClick = function () { _this2.handleSelect(); if (props.checkable) { _this2.handleCheck(); } }; } return _react2['default'].createElement( 'a', _extends({ ref: 'selectHandle', title: content }, domProps), icon, title ); }; return _react2['default'].createElement( 'li', { className: (0, _rcUtil.joinClasses)(props.className, props.disabled ? prefixCls + '-treenode-disabled' : '') }, canRenderSwitcher ? this.renderSwitcher(props, expandedState) : _react2['default'].createElement('span', { className: prefixCls + '-switcher-noop' }), props.checkable ? this.renderCheckbox(props) : null, selectHandle(), newChildren ); } }, { key: 'handleCheck', value: function handleCheck() { this.props.root.handleCheck(this); } }, { key: 'handleSelect', value: function handleSelect() { this.props.root.handleSelect(this); } }, { key: 'handleExpand', value: function handleExpand() { this.props.root.handleExpand(this); } // keyboard event support }, { key: 'handleKeyDown', value: function handleKeyDown(e) { e.preventDefault(); } }]); return TreeNode; })(_react2['default'].Component); TreeNode.propTypes = { prefixCls: _react2['default'].PropTypes.string, expanded: _react2['default'].PropTypes.bool, root: _react2['default'].PropTypes.object, onSelect: _react2['default'].PropTypes.func }; TreeNode.defaultProps = { title: defaultTitle }; exports['default'] = TreeNode; module.exports = exports['default']; /***/ }, /* 339 */ /***/ function(module, exports) { 'use strict'; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function ToObject(val) { if (val == null) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function ownEnumerableKeys(obj) { var keys = Object.getOwnPropertyNames(obj); if (Object.getOwnPropertySymbols) { keys = keys.concat(Object.getOwnPropertySymbols(obj)); } return keys.filter(function (key) { return propIsEnumerable.call(obj, key); }); } module.exports = Object.assign || function (target, source) { var from; var keys; var to = ToObject(target); for (var s = 1; s < arguments.length; s++) { from = arguments[s]; keys = ownEnumerableKeys(Object(from)); for (var i = 0; i < keys.length; i++) { to[keys[i]] = from[keys[i]]; } } return to; }; /***/ }, /* 340 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var velocity = undefined; if (typeof document !== 'undefined' && typeof window !== 'undefined') { velocity = __webpack_require__(284); } function animate(node, show, transitionName, done) { var ok = undefined; function complete() { if (!ok) { ok = true; done(); } } // Fix safari flash bug node.style.display = show ? 'block' : 'none'; velocity(node, transitionName, { duration: 240, complete: complete, easing: 'easeInOutQuad' }); return { stop: function stop() { velocity(node, 'finish'); complete(); } }; } var animation = { enter: function enter(node, done) { return animate(node, false, 'slideDown', done); }, leave: function leave(node, done) { return animate(node, true, 'slideUp', done); }, appear: function appear(node, done) { return animate(node, false, 'slideDown', done); } }; module.exports = animation; /***/ }, /* 341 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcUpload = __webpack_require__(342); var _rcUpload2 = _interopRequireDefault(_rcUpload); var _objectAssign = __webpack_require__(184); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _uploadList = __webpack_require__(351); var _uploadList2 = _interopRequireDefault(_uploadList); var _getFileItem = __webpack_require__(352); var _getFileItem2 = _interopRequireDefault(_getFileItem); var prefixCls = 'ant-upload'; function noop() {} // Fix IE file.status problem // via coping a new Object function fileToObject(file) { return { lastModified: file.lastModified, lastModifiedDate: file.lastModifiedDate, name: file.filename || file.name, size: file.size, type: file.type, uid: file.uid, response: file.response, error: file.error }; } var AntUpload = _react2['default'].createClass({ displayName: 'AntUpload', getInitialState: function getInitialState() { return { fileList: this.props.fileList || this.props.defaultFileList || [] }; }, onStart: function onStart(file) { var targetItem = undefined; var nextFileList = this.state.fileList.concat(); if (file.length > 0) { targetItem = file.map(function (f) { f = fileToObject(f); f.status = 'uploading'; return f; }); nextFileList = nextFileList.concat(file); } else { targetItem = fileToObject(file); targetItem.status = 'uploading'; nextFileList.push(targetItem); } this.onChange({ file: targetItem, fileList: nextFileList }); }, removeFile: function removeFile(file) { var fileList = this.state.fileList; var targetItem = (0, _getFileItem2['default'])(file, fileList); var index = fileList.indexOf(targetItem); if (index !== -1) { fileList.splice(index, 1); return fileList; } return null; }, onSuccess: function onSuccess(response, file) { // 服务器端需要返回标准 json 字符串 // 否则视为失败 try { if (typeof response === 'string') { JSON.parse(response); } } catch (e) { this.onError(new Error('No response'), response, file); return; } var fileList = this.state.fileList; var targetItem = (0, _getFileItem2['default'])(file, fileList); // 之前已经删除 if (targetItem) { targetItem.status = 'done'; targetItem.response = response; this.onChange({ file: targetItem, fileList: fileList }); } }, onProgress: function onProgress(e, file) { var fileList = this.state.fileList; var targetItem = (0, _getFileItem2['default'])(file, fileList); if (targetItem) { this.onChange({ event: e, file: file, fileList: this.state.fileList }); } }, onError: function onError(error, response, file) { var fileList = this.state.fileList; var targetItem = (0, _getFileItem2['default'])(file, fileList); targetItem.error = error; targetItem.response = response; targetItem.status = 'error'; this.handleRemove(targetItem); }, handleRemove: function handleRemove(file) { var fileList = this.removeFile(file); if (fileList) { this.onChange({ file: file, fileList: fileList }); } }, handleManualRemove: function handleManualRemove(file) { file.status = 'removed'; this.handleRemove(file); }, onChange: function onChange(info) { // 1. 有设置外部属性时不改变 fileList // 2. 上传中状态(info.event)不改变 fileList if (!('fileList' in this.props) && !info.event) { this.setState({ fileList: info.fileList }); } this.props.onChange(info); }, getDefaultProps: function getDefaultProps() { return { type: 'select', name: '', multipart: false, action: '', data: {}, accept: '', onChange: noop }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('fileList' in nextProps) { this.setState({ fileList: nextProps.fileList }); } }, render: function render() { var type = this.props.type || 'select'; var props = (0, _objectAssign2['default'])({}, this.props, { onStart: this.onStart, onError: this.onError, onProgress: this.onProgress, onSuccess: this.onSuccess }); if (type === 'drag') { return _react2['default'].createElement( 'div', { className: prefixCls + ' ' + prefixCls + '-drag' }, _react2['default'].createElement( _rcUpload2['default'], props, _react2['default'].createElement( 'div', { className: prefixCls + '-drag-container' }, this.props.children ) ) ); } else if (type === 'select') { return _react2['default'].createElement( 'div', null, _react2['default'].createElement( 'div', { className: prefixCls + ' ' + prefixCls + '-select' }, _react2['default'].createElement( _rcUpload2['default'], props, this.props.children ) ), _react2['default'].createElement(_uploadList2['default'], { items: this.state.fileList, onRemove: this.handleManualRemove }) ); } } }); AntUpload.Dragger = _react2['default'].createClass({ displayName: 'Dragger', render: function render() { return _react2['default'].createElement(AntUpload, _extends({}, this.props, { type: 'drag', style: { height: this.props.height } })); } }); exports['default'] = AntUpload; module.exports = exports['default']; /***/ }, /* 342 */ /***/ function(module, exports, __webpack_require__) { // export this package's api 'use strict'; module.exports = __webpack_require__(343); /***/ }, /* 343 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _AjaxUploader = __webpack_require__(344); var _AjaxUploader2 = _interopRequireDefault(_AjaxUploader); var _IframeUploader = __webpack_require__(349); var _IframeUploader2 = _interopRequireDefault(_IframeUploader); function empty() {} var Upload = _react2['default'].createClass({ displayName: 'Upload', propTypes: { forceAjax: _react.PropTypes.bool, action: _react.PropTypes.string, name: _react.PropTypes.string, multipart: _react.PropTypes.bool, onError: _react.PropTypes.func, onSuccess: _react.PropTypes.func, onProgress: _react.PropTypes.func, onStart: _react.PropTypes.func, data: _react.PropTypes.object, accept: _react.PropTypes.string, multiple: _react.PropTypes.bool, beforeUpload: _react.PropTypes.func }, getDefaultProps: function getDefaultProps() { return { data: {}, name: 'file', forceAjax: false, multipart: false, onProgress: empty, onStart: empty, onError: empty, onSuccess: empty, multiple: false, beforeUpload: null }; }, render: function render() { var props = this.props; // node 渲染根据 ua 强制设置 forceAjax 或者支持FormData的情况使用AjaxUpload if (props.forceAjax || typeof FormData !== 'undefined') { return _react2['default'].createElement(_AjaxUploader2['default'], props); } return _react2['default'].createElement(_IframeUploader2['default'], props); } }); exports['default'] = Upload; module.exports = exports['default']; /***/ }, /* 344 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _superagent = __webpack_require__(345); var _superagent2 = _interopRequireDefault(_superagent); var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _uid = __webpack_require__(348); var _uid2 = _interopRequireDefault(_uid); var AjaxUploader = _react2['default'].createClass({ displayName: 'AjaxUploader', propTypes: { multiple: _react.PropTypes.bool, onStart: _react.PropTypes.func, data: _react.PropTypes.object, beforeUpload: _react.PropTypes.func }, onChange: function onChange(e) { var files = e.target.files; this.uploadFiles(files); }, onClick: function onClick() { var el = _react2['default'].findDOMNode(this.refs.file); if (!el) { return; } el.click(); el.value = ''; }, onKeyDown: function onKeyDown(e) { if (e.key === 'Enter') { this.onClick(); } }, onFileDrop: function onFileDrop(e) { if (e.type === 'dragover') { return e.preventDefault(); } var files = e.dataTransfer.files; this.uploadFiles(files); e.preventDefault(); }, render: function render() { var hidden = { display: 'none' }; var props = this.props; return _react2['default'].createElement( 'span', { onClick: this.onClick, onKeyDown: this.onKeyDown, onDrop: this.onFileDrop, onDragOver: this.onFileDrop, role: 'button', tabIndex: '0' }, _react2['default'].createElement('input', { type: 'file', ref: 'file', style: hidden, accept: props.accept, multiple: this.props.multiple, onChange: this.onChange }), props.children ); }, uploadFiles: function uploadFiles(files) { var len = files.length; if (len > 0) { for (var i = 0; i < len; i++) { var file = files.item(i); file.uid = (0, _uid2['default'])(); this.upload(file); } if (this.props.multiple) { this.props.onStart(Array.prototype.slice.call(files)); } else { this.props.onStart(Array.prototype.slice.call(files)[0]); } } }, upload: function upload(file) { var _this = this; var props = this.props; if (!props.beforeUpload) { return this.post(file); } var before = props.beforeUpload(file); if (before && before.then) { before.then(function () { _this.post(file); }); } else if (before !== false) { this.post(file); } }, post: function post(file) { var props = this.props; var req = _superagent2['default'].post(props.action).attach(props.name, file, file.name); var data = props.data; if (typeof data === 'function') { data = data(); } for (var key in data) { if (data.hasOwnProperty(key)) { req.field(key, data[key]); } } function progress(e) { props.onProgress(e, file); } req.on('progress', progress); req.end(function (err, ret) { req.off('progress', progress); if (err || ret.status !== 200) { props.onError(err, ret, file); return; } props.onSuccess(ret.body || ret.text, file); }); } }); exports['default'] = AjaxUploader; module.exports = exports['default']; /***/ }, /* 345 */ /***/ function(module, exports, __webpack_require__) { /** * Module dependencies. */ var Emitter = __webpack_require__(346); var reduce = __webpack_require__(347); /** * Root reference for iframes. */ var root; if (typeof window !== 'undefined') { // Browser window root = window; } else if (typeof self !== 'undefined') { // Web Worker root = self; } else { // Other environments root = this; } /** * Noop. */ function noop(){}; /** * Check if `obj` is a host object, * we don't want to serialize these :) * * TODO: future proof, move to compoent land * * @param {Object} obj * @return {Boolean} * @api private */ function isHost(obj) { var str = {}.toString.call(obj); switch (str) { case '[object File]': case '[object Blob]': case '[object FormData]': return true; default: return false; } } /** * Determine XHR. */ request.getXHR = function () { if (root.XMLHttpRequest && (!root.location || 'file:' != root.location.protocol || !root.ActiveXObject)) { return new XMLHttpRequest; } else { try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {} try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {} try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {} try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {} } return false; }; /** * Removes leading and trailing whitespace, added to support IE. * * @param {String} s * @return {String} * @api private */ var trim = ''.trim ? function(s) { return s.trim(); } : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); }; /** * Check if `obj` is an object. * * @param {Object} obj * @return {Boolean} * @api private */ function isObject(obj) { return obj === Object(obj); } /** * Serialize the given `obj`. * * @param {Object} obj * @return {String} * @api private */ function serialize(obj) { if (!isObject(obj)) return obj; var pairs = []; for (var key in obj) { if (null != obj[key]) { pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key])); } } return pairs.join('&'); } /** * Expose serialization method. */ request.serializeObject = serialize; /** * Parse the given x-www-form-urlencoded `str`. * * @param {String} str * @return {Object} * @api private */ function parseString(str) { var obj = {}; var pairs = str.split('&'); var parts; var pair; for (var i = 0, len = pairs.length; i < len; ++i) { pair = pairs[i]; parts = pair.split('='); obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]); } return obj; } /** * Expose parser. */ request.parseString = parseString; /** * Default MIME type map. * * superagent.types.xml = 'application/xml'; * */ request.types = { html: 'text/html', json: 'application/json', xml: 'application/xml', urlencoded: 'application/x-www-form-urlencoded', 'form': 'application/x-www-form-urlencoded', 'form-data': 'application/x-www-form-urlencoded' }; /** * Default serialization map. * * superagent.serialize['application/xml'] = function(obj){ * return 'generated xml here'; * }; * */ request.serialize = { 'application/x-www-form-urlencoded': serialize, 'application/json': JSON.stringify }; /** * Default parsers. * * superagent.parse['application/xml'] = function(str){ * return { object parsed from str }; * }; * */ request.parse = { 'application/x-www-form-urlencoded': parseString, 'application/json': JSON.parse }; /** * Parse the given header `str` into * an object containing the mapped fields. * * @param {String} str * @return {Object} * @api private */ function parseHeader(str) { var lines = str.split(/\r?\n/); var fields = {}; var index; var line; var field; var val; lines.pop(); // trailing CRLF for (var i = 0, len = lines.length; i < len; ++i) { line = lines[i]; index = line.indexOf(':'); field = line.slice(0, index).toLowerCase(); val = trim(line.slice(index + 1)); fields[field] = val; } return fields; } /** * Return the mime type for the given `str`. * * @param {String} str * @return {String} * @api private */ function type(str){ return str.split(/ *; */).shift(); }; /** * Return header field parameters. * * @param {String} str * @return {Object} * @api private */ function params(str){ return reduce(str.split(/ *; */), function(obj, str){ var parts = str.split(/ *= */) , key = parts.shift() , val = parts.shift(); if (key && val) obj[key] = val; return obj; }, {}); }; /** * Initialize a new `Response` with the given `xhr`. * * - set flags (.ok, .error, etc) * - parse header * * Examples: * * Aliasing `superagent` as `request` is nice: * * request = superagent; * * We can use the promise-like API, or pass callbacks: * * request.get('/').end(function(res){}); * request.get('/', function(res){}); * * Sending data can be chained: * * request * .post('/user') * .send({ name: 'tj' }) * .end(function(res){}); * * Or passed to `.send()`: * * request * .post('/user') * .send({ name: 'tj' }, function(res){}); * * Or passed to `.post()`: * * request * .post('/user', { name: 'tj' }) * .end(function(res){}); * * Or further reduced to a single call for simple cases: * * request * .post('/user', { name: 'tj' }, function(res){}); * * @param {XMLHTTPRequest} xhr * @param {Object} options * @api private */ function Response(req, options) { options = options || {}; this.req = req; this.xhr = this.req.xhr; // responseText is accessible only if responseType is '' or 'text' and on older browsers this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined') ? this.xhr.responseText : null; this.statusText = this.req.xhr.statusText; this.setStatusProperties(this.xhr.status); this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders()); // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but // getResponseHeader still works. so we get content-type even if getting // other headers fails. this.header['content-type'] = this.xhr.getResponseHeader('content-type'); this.setHeaderProperties(this.header); this.body = this.req.method != 'HEAD' ? this.parseBody(this.text ? this.text : this.xhr.response) : null; } /** * Get case-insensitive `field` value. * * @param {String} field * @return {String} * @api public */ Response.prototype.get = function(field){ return this.header[field.toLowerCase()]; }; /** * Set header related properties: * * - `.type` the content type without params * * A response of "Content-Type: text/plain; charset=utf-8" * will provide you with a `.type` of "text/plain". * * @param {Object} header * @api private */ Response.prototype.setHeaderProperties = function(header){ // content-type var ct = this.header['content-type'] || ''; this.type = type(ct); // params var obj = params(ct); for (var key in obj) this[key] = obj[key]; }; /** * Force given parser * * Sets the body parser no matter type. * * @param {Function} * @api public */ Response.prototype.parse = function(fn){ this.parser = fn; return this; }; /** * Parse the given body `str`. * * Used for auto-parsing of bodies. Parsers * are defined on the `superagent.parse` object. * * @param {String} str * @return {Mixed} * @api private */ Response.prototype.parseBody = function(str){ var parse = this.parser || request.parse[this.type]; return parse && str && (str.length || str instanceof Object) ? parse(str) : null; }; /** * Set flags such as `.ok` based on `status`. * * For example a 2xx response will give you a `.ok` of __true__ * whereas 5xx will be __false__ and `.error` will be __true__. The * `.clientError` and `.serverError` are also available to be more * specific, and `.statusType` is the class of error ranging from 1..5 * sometimes useful for mapping respond colors etc. * * "sugar" properties are also defined for common cases. Currently providing: * * - .noContent * - .badRequest * - .unauthorized * - .notAcceptable * - .notFound * * @param {Number} status * @api private */ Response.prototype.setStatusProperties = function(status){ // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request if (status === 1223) { status = 204; } var type = status / 100 | 0; // status / class this.status = this.statusCode = status; this.statusType = type; // basics this.info = 1 == type; this.ok = 2 == type; this.clientError = 4 == type; this.serverError = 5 == type; this.error = (4 == type || 5 == type) ? this.toError() : false; // sugar this.accepted = 202 == status; this.noContent = 204 == status; this.badRequest = 400 == status; this.unauthorized = 401 == status; this.notAcceptable = 406 == status; this.notFound = 404 == status; this.forbidden = 403 == status; }; /** * Return an `Error` representative of this response. * * @return {Error} * @api public */ Response.prototype.toError = function(){ var req = this.req; var method = req.method; var url = req.url; var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')'; var err = new Error(msg); err.status = this.status; err.method = method; err.url = url; return err; }; /** * Expose `Response`. */ request.Response = Response; /** * Initialize a new `Request` with the given `method` and `url`. * * @param {String} method * @param {String} url * @api public */ function Request(method, url) { var self = this; Emitter.call(this); this._query = this._query || []; this.method = method; this.url = url; this.header = {}; this._header = {}; this.on('end', function(){ var err = null; var res = null; try { res = new Response(self); } catch(e) { err = new Error('Parser is unable to parse the response'); err.parse = true; err.original = e; return self.callback(err); } self.emit('response', res); if (err) { return self.callback(err, res); } if (res.status >= 200 && res.status < 300) { return self.callback(err, res); } var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); new_err.original = err; new_err.response = res; new_err.status = res.status; self.callback(new_err, res); }); } /** * Mixin `Emitter`. */ Emitter(Request.prototype); /** * Allow for extension */ Request.prototype.use = function(fn) { fn(this); return this; } /** * Set timeout to `ms`. * * @param {Number} ms * @return {Request} for chaining * @api public */ Request.prototype.timeout = function(ms){ this._timeout = ms; return this; }; /** * Clear previous timeout. * * @return {Request} for chaining * @api public */ Request.prototype.clearTimeout = function(){ this._timeout = 0; clearTimeout(this._timer); return this; }; /** * Abort the request, and clear potential timeout. * * @return {Request} * @api public */ Request.prototype.abort = function(){ if (this.aborted) return; this.aborted = true; this.xhr.abort(); this.clearTimeout(); this.emit('abort'); return this; }; /** * Set header `field` to `val`, or multiple fields with one object. * * Examples: * * req.get('/') * .set('Accept', 'application/json') * .set('X-API-Key', 'foobar') * .end(callback); * * req.get('/') * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) * .end(callback); * * @param {String|Object} field * @param {String} val * @return {Request} for chaining * @api public */ Request.prototype.set = function(field, val){ if (isObject(field)) { for (var key in field) { this.set(key, field[key]); } return this; } this._header[field.toLowerCase()] = val; this.header[field] = val; return this; }; /** * Remove header `field`. * * Example: * * req.get('/') * .unset('User-Agent') * .end(callback); * * @param {String} field * @return {Request} for chaining * @api public */ Request.prototype.unset = function(field){ delete this._header[field.toLowerCase()]; delete this.header[field]; return this; }; /** * Get case-insensitive header `field` value. * * @param {String} field * @return {String} * @api private */ Request.prototype.getHeader = function(field){ return this._header[field.toLowerCase()]; }; /** * Set Content-Type to `type`, mapping values from `request.types`. * * Examples: * * superagent.types.xml = 'application/xml'; * * request.post('/') * .type('xml') * .send(xmlstring) * .end(callback); * * request.post('/') * .type('application/xml') * .send(xmlstring) * .end(callback); * * @param {String} type * @return {Request} for chaining * @api public */ Request.prototype.type = function(type){ this.set('Content-Type', request.types[type] || type); return this; }; /** * Set Accept to `type`, mapping values from `request.types`. * * Examples: * * superagent.types.json = 'application/json'; * * request.get('/agent') * .accept('json') * .end(callback); * * request.get('/agent') * .accept('application/json') * .end(callback); * * @param {String} accept * @return {Request} for chaining * @api public */ Request.prototype.accept = function(type){ this.set('Accept', request.types[type] || type); return this; }; /** * Set Authorization field value with `user` and `pass`. * * @param {String} user * @param {String} pass * @return {Request} for chaining * @api public */ Request.prototype.auth = function(user, pass){ var str = btoa(user + ':' + pass); this.set('Authorization', 'Basic ' + str); return this; }; /** * Add query-string `val`. * * Examples: * * request.get('/shoes') * .query('size=10') * .query({ color: 'blue' }) * * @param {Object|String} val * @return {Request} for chaining * @api public */ Request.prototype.query = function(val){ if ('string' != typeof val) val = serialize(val); if (val) this._query.push(val); return this; }; /** * Write the field `name` and `val` for "multipart/form-data" * request bodies. * * ``` js * request.post('/upload') * .field('foo', 'bar') * .end(callback); * ``` * * @param {String} name * @param {String|Blob|File} val * @return {Request} for chaining * @api public */ Request.prototype.field = function(name, val){ if (!this._formData) this._formData = new root.FormData(); this._formData.append(name, val); return this; }; /** * Queue the given `file` as an attachment to the specified `field`, * with optional `filename`. * * ``` js * request.post('/upload') * .attach(new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"})) * .end(callback); * ``` * * @param {String} field * @param {Blob|File} file * @param {String} filename * @return {Request} for chaining * @api public */ Request.prototype.attach = function(field, file, filename){ if (!this._formData) this._formData = new root.FormData(); this._formData.append(field, file, filename); return this; }; /** * Send `data`, defaulting the `.type()` to "json" when * an object is given. * * Examples: * * // querystring * request.get('/search') * .end(callback) * * // multiple data "writes" * request.get('/search') * .send({ search: 'query' }) * .send({ range: '1..5' }) * .send({ order: 'desc' }) * .end(callback) * * // manual json * request.post('/user') * .type('json') * .send('{"name":"tj"}) * .end(callback) * * // auto json * request.post('/user') * .send({ name: 'tj' }) * .end(callback) * * // manual x-www-form-urlencoded * request.post('/user') * .type('form') * .send('name=tj') * .end(callback) * * // auto x-www-form-urlencoded * request.post('/user') * .type('form') * .send({ name: 'tj' }) * .end(callback) * * // defaults to x-www-form-urlencoded * request.post('/user') * .send('name=tobi') * .send('species=ferret') * .end(callback) * * @param {String|Object} data * @return {Request} for chaining * @api public */ Request.prototype.send = function(data){ var obj = isObject(data); var type = this.getHeader('Content-Type'); // merge if (obj && isObject(this._data)) { for (var key in data) { this._data[key] = data[key]; } } else if ('string' == typeof data) { if (!type) this.type('form'); type = this.getHeader('Content-Type'); if ('application/x-www-form-urlencoded' == type) { this._data = this._data ? this._data + '&' + data : data; } else { this._data = (this._data || '') + data; } } else { this._data = data; } if (!obj || isHost(data)) return this; if (!type) this.type('json'); return this; }; /** * Invoke the callback with `err` and `res` * and handle arity check. * * @param {Error} err * @param {Response} res * @api private */ Request.prototype.callback = function(err, res){ var fn = this._callback; this.clearTimeout(); fn(err, res); }; /** * Invoke callback with x-domain error. * * @api private */ Request.prototype.crossDomainError = function(){ var err = new Error('Origin is not allowed by Access-Control-Allow-Origin'); err.crossDomain = true; this.callback(err); }; /** * Invoke callback with timeout error. * * @api private */ Request.prototype.timeoutError = function(){ var timeout = this._timeout; var err = new Error('timeout of ' + timeout + 'ms exceeded'); err.timeout = timeout; this.callback(err); }; /** * Enable transmission of cookies with x-domain requests. * * Note that for this to work the origin must not be * using "Access-Control-Allow-Origin" with a wildcard, * and also must set "Access-Control-Allow-Credentials" * to "true". * * @api public */ Request.prototype.withCredentials = function(){ this._withCredentials = true; return this; }; /** * Initiate request, invoking callback `fn(res)` * with an instanceof `Response`. * * @param {Function} fn * @return {Request} for chaining * @api public */ Request.prototype.end = function(fn){ var self = this; var xhr = this.xhr = request.getXHR(); var query = this._query.join('&'); var timeout = this._timeout; var data = this._formData || this._data; // store callback this._callback = fn || noop; // state change xhr.onreadystatechange = function(){ if (4 != xhr.readyState) return; // In IE9, reads to any property (e.g. status) off of an aborted XHR will // result in the error "Could not complete the operation due to error c00c023f" var status; try { status = xhr.status } catch(e) { status = 0; } if (0 == status) { if (self.timedout) return self.timeoutError(); if (self.aborted) return; return self.crossDomainError(); } self.emit('end'); }; // progress var handleProgress = function(e){ if (e.total > 0) { e.percent = e.loaded / e.total * 100; } self.emit('progress', e); }; if (this.hasListeners('progress')) { xhr.onprogress = handleProgress; } try { if (xhr.upload && this.hasListeners('progress')) { xhr.upload.onprogress = handleProgress; } } catch(e) { // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. // Reported here: // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context } // timeout if (timeout && !this._timer) { this._timer = setTimeout(function(){ self.timedout = true; self.abort(); }, timeout); } // querystring if (query) { query = request.serializeObject(query); this.url += ~this.url.indexOf('?') ? '&' + query : '?' + query; } // initiate request xhr.open(this.method, this.url, true); // CORS if (this._withCredentials) xhr.withCredentials = true; // body if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) { // serialize stuff var contentType = this.getHeader('Content-Type'); var serialize = request.serialize[contentType ? contentType.split(';')[0] : '']; if (serialize) data = serialize(data); } // set header fields for (var field in this.header) { if (null == this.header[field]) continue; xhr.setRequestHeader(field, this.header[field]); } // send stuff this.emit('request', this); xhr.send(data); return this; }; /** * Faux promise support * * @param {Function} fulfill * @param {Function} reject * @return {Request} */ Request.prototype.then = function (fulfill, reject) { return this.end(function(err, res) { err ? reject(err) : fulfill(res); }); } /** * Expose `Request`. */ request.Request = Request; /** * Issue a request: * * Examples: * * request('GET', '/users').end(callback) * request('/users').end(callback) * request('/users', callback) * * @param {String} method * @param {String|Function} url or callback * @return {Request} * @api public */ function request(method, url) { // callback if ('function' == typeof url) { return new Request('GET', method).end(url); } // url first if (1 == arguments.length) { return new Request('GET', method); } return new Request(method, url); } /** * GET `url` with optional callback `fn(res)`. * * @param {String} url * @param {Mixed|Function} data or fn * @param {Function} fn * @return {Request} * @api public */ request.get = function(url, data, fn){ var req = request('GET', url); if ('function' == typeof data) fn = data, data = null; if (data) req.query(data); if (fn) req.end(fn); return req; }; /** * HEAD `url` with optional callback `fn(res)`. * * @param {String} url * @param {Mixed|Function} data or fn * @param {Function} fn * @return {Request} * @api public */ request.head = function(url, data, fn){ var req = request('HEAD', url); if ('function' == typeof data) fn = data, data = null; if (data) req.send(data); if (fn) req.end(fn); return req; }; /** * DELETE `url` with optional callback `fn(res)`. * * @param {String} url * @param {Function} fn * @return {Request} * @api public */ request.del = function(url, fn){ var req = request('DELETE', url); if (fn) req.end(fn); return req; }; /** * PATCH `url` with optional `data` and callback `fn(res)`. * * @param {String} url * @param {Mixed} data * @param {Function} fn * @return {Request} * @api public */ request.patch = function(url, data, fn){ var req = request('PATCH', url); if ('function' == typeof data) fn = data, data = null; if (data) req.send(data); if (fn) req.end(fn); return req; }; /** * POST `url` with optional `data` and callback `fn(res)`. * * @param {String} url * @param {Mixed} data * @param {Function} fn * @return {Request} * @api public */ request.post = function(url, data, fn){ var req = request('POST', url); if ('function' == typeof data) fn = data, data = null; if (data) req.send(data); if (fn) req.end(fn); return req; }; /** * PUT `url` with optional `data` and callback `fn(res)`. * * @param {String} url * @param {Mixed|Function} data or fn * @param {Function} fn * @return {Request} * @api public */ request.put = function(url, data, fn){ var req = request('PUT', url); if ('function' == typeof data) fn = data, data = null; if (data) req.send(data); if (fn) req.end(fn); return req; }; /** * Expose `request`. */ module.exports = request; /***/ }, /* 346 */ /***/ function(module, exports) { /** * Expose `Emitter`. */ module.exports = Emitter; /** * Initialize a new `Emitter`. * * @api public */ function Emitter(obj) { if (obj) return mixin(obj); }; /** * Mixin the emitter properties. * * @param {Object} obj * @return {Object} * @api private */ function mixin(obj) { for (var key in Emitter.prototype) { obj[key] = Emitter.prototype[key]; } return obj; } /** * Listen on the given `event` with `fn`. * * @param {String} event * @param {Function} fn * @return {Emitter} * @api public */ Emitter.prototype.on = Emitter.prototype.addEventListener = function(event, fn){ this._callbacks = this._callbacks || {}; (this._callbacks[event] = this._callbacks[event] || []) .push(fn); return this; }; /** * Adds an `event` listener that will be invoked a single * time then automatically removed. * * @param {String} event * @param {Function} fn * @return {Emitter} * @api public */ Emitter.prototype.once = function(event, fn){ var self = this; this._callbacks = this._callbacks || {}; function on() { self.off(event, on); fn.apply(this, arguments); } on.fn = fn; this.on(event, on); return this; }; /** * Remove the given callback for `event` or all * registered callbacks. * * @param {String} event * @param {Function} fn * @return {Emitter} * @api public */ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function(event, fn){ this._callbacks = this._callbacks || {}; // all if (0 == arguments.length) { this._callbacks = {}; return this; } // specific event var callbacks = this._callbacks[event]; if (!callbacks) return this; // remove all handlers if (1 == arguments.length) { delete this._callbacks[event]; return this; } // remove specific handler var cb; for (var i = 0; i < callbacks.length; i++) { cb = callbacks[i]; if (cb === fn || cb.fn === fn) { callbacks.splice(i, 1); break; } } return this; }; /** * Emit `event` with the given args. * * @param {String} event * @param {Mixed} ... * @return {Emitter} */ Emitter.prototype.emit = function(event){ this._callbacks = this._callbacks || {}; var args = [].slice.call(arguments, 1) , callbacks = this._callbacks[event]; if (callbacks) { callbacks = callbacks.slice(0); for (var i = 0, len = callbacks.length; i < len; ++i) { callbacks[i].apply(this, args); } } return this; }; /** * Return array of callbacks for `event`. * * @param {String} event * @return {Array} * @api public */ Emitter.prototype.listeners = function(event){ this._callbacks = this._callbacks || {}; return this._callbacks[event] || []; }; /** * Check if this emitter has `event` handlers. * * @param {String} event * @return {Boolean} * @api public */ Emitter.prototype.hasListeners = function(event){ return !! this.listeners(event).length; }; /***/ }, /* 347 */ /***/ function(module, exports) { /** * Reduce `arr` with `fn`. * * @param {Array} arr * @param {Function} fn * @param {Mixed} initial * * TODO: combatible error handling? */ module.exports = function(arr, fn, initial){ var idx = 0; var len = arr.length; var curr = arguments.length == 3 ? initial : arr[idx++]; while (idx < len) { curr = fn.call(null, curr, arr[idx], ++idx, arr); } return curr; }; /***/ }, /* 348 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports['default'] = uid; var now = +new Date(); var index = 0; function uid() { return 'rc-upload-' + now + '-' + ++index; } module.exports = exports['default']; /***/ }, /* 349 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _uid = __webpack_require__(348); var _uid2 = _interopRequireDefault(_uid); var _warning = __webpack_require__(350); var _warning2 = _interopRequireDefault(_warning); var iframeStyle = { position: 'absolute', top: 0, opacity: 0, filter: 'alpha(opacity=0)', left: 0, zIndex: 9999 }; var IframeUploader = _react2['default'].createClass({ displayName: 'IframeUploader', propTypes: { onStart: _react.PropTypes.func, multiple: _react.PropTypes.bool, children: _react.PropTypes.any, data: _react.PropTypes.object, action: _react.PropTypes.string, name: _react.PropTypes.string }, componentDidMount: function componentDidMount() { this.updateIframeWH(); this.initIframe(); }, componentDidUpdate: function componentDidUpdate() { this.updateIframeWH(); }, onLoad: function onLoad() { if (!this.loading) { return; } var props = this.props; var response = undefined; var eventFile = this.file; try { var doc = this.getIframeDocument(); var script = doc.getElementsByTagName('script')[0]; if (script && script.parentNode === doc.body) { doc.body.removeChild(script); } response = doc.body.innerHTML; props.onSuccess(response, eventFile); } catch (err) { (0, _warning2['default'])(false, 'cross domain error for Upload. Maybe server should return document.domain script. see Note from https://github.com/react-component/upload'); response = 'cross-domain'; props.onError(err, null, eventFile); } this.enableIframe(); this.initIframe(); }, onChange: function onChange() { var target = this.getFormInputNode(); // ie8/9 don't support FileList Object // http://stackoverflow.com/questions/12830058/ie8-input-type-file-get-files var file = this.file = { uid: (0, _uid2['default'])(), name: target.value }; this.props.onStart(this.getFileForMultiple(file)); var formNode = this.getFormNode(); var dataSpan = this.getFormDataNode(); var data = this.props.data; if (typeof data === 'function') { data = data(); } var inputs = []; for (var key in data) { if (data.hasOwnProperty(key)) { inputs.push('<input name="' + key + '" value="' + data[key] + '"/>'); } } dataSpan.innerHTML = inputs.join(''); formNode.submit(); dataSpan.innerHTML = ''; this.disabledIframe(); }, getIframeNode: function getIframeNode() { return _react2['default'].findDOMNode(this.refs.iframe); }, getIframeDocument: function getIframeDocument() { return this.getIframeNode().contentDocument; }, getFormNode: function getFormNode() { return this.getIframeDocument().getElementById('form'); }, getFormInputNode: function getFormInputNode() { return this.getIframeDocument().getElementById('input'); }, getFormDataNode: function getFormDataNode() { return this.getIframeDocument().getElementById('data'); }, getFileForMultiple: function getFileForMultiple(file) { return this.props.multiple ? [file] : file; }, getIframeHTML: function getIframeHTML(domain) { var domainScript = ''; var domainInput = ''; if (domain) { domainScript = '<script>document.domain="' + domain + '";</script>'; domainInput = '<input name="_documentDomain" value="' + domain + '" />'; } return '\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\n <style>\n body,html {padding:0;margin:0;border:0;overflow:hidden;}\n </style>\n ' + domainScript + '\n </head>\n <body>\n <form method="post"\n encType="multipart/form-data"\n action="' + this.props.action + '" id="form" style="display:block;height:9999px;position:relative;overflow:hidden;">\n <input id="input" type="file"\n name="' + this.props.name + '"\n style="position:absolute;top:0;right:0;height:9999px;font-size:9999px;cursor:pointer;"/>\n ' + domainInput + '\n <span id="data"></span>\n </form>\n </body>\n </html>\n '; }, render: function render() { return _react2['default'].createElement( 'span', { style: { position: 'relative', zIndex: 0 } }, _react2['default'].createElement('iframe', { ref: 'iframe', onLoad: this.onLoad, style: iframeStyle }), this.props.children ); }, initIframeSrc: function initIframeSrc() { if (this.domain) { this.getIframeNode().src = 'javascript:void((function(){\n var d = document;\n d.open();\n d.domain=\'' + this.domain + '\';\n d.write(\'\');\n d.close();\n })())'; } }, initIframe: function initIframe() { var iframeNode = this.getIframeNode(); var win = iframeNode.contentWindow; var doc = undefined; this.domain = this.domain || ''; this.initIframeSrc(); try { doc = win.document; } catch (e) { this.domain = document.domain; this.initIframeSrc(); win = iframeNode.contentWindow; doc = win.document; } doc.open('text/html', 'replace'); doc.write(this.getIframeHTML(this.domain)); doc.close(); this.getFormInputNode().onchange = this.onChange; }, enableIframe: function enableIframe() { this.loading = false; this.getIframeNode().style.display = ''; }, disabledIframe: function disabledIframe() { this.loading = true; this.getIframeNode().style.display = 'none'; }, updateIframeWH: function updateIframeWH() { var rootNode = _react2['default'].findDOMNode(this); var iframeNode = this.getIframeNode(); iframeNode.style.height = rootNode.offsetHeight + 'px'; iframeNode.style.width = rootNode.offsetWidth + 'px'; } }); exports['default'] = IframeUploader; module.exports = exports['default']; /***/ }, /* 350 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; /** * Similar to invariant but only logs a warning if the condition is not met. * This can be used to log issues in development environments in critical * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ var warning = function() {}; if (process.env.NODE_ENV !== 'production') { warning = function(condition, format, args) { var len = arguments.length; args = new Array(len > 2 ? len - 2 : 0); for (var key = 2; key < len; key++) { args[key - 2] = arguments[key]; } if (format === undefined) { throw new Error( '`warning(condition, format, ...args)` requires a warning ' + 'message argument' ); } if (format.length < 10 || (/^[s\W]*$/).test(format)) { throw new Error( 'The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format ); } if (!condition) { var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function() { return args[argIndex++]; }); if (typeof console !== 'undefined') { console.error(message); } try { // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch(x) {} } }; } module.exports = warning; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(166))) /***/ }, /* 351 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcAnimate = __webpack_require__(124); var _rcAnimate2 = _interopRequireDefault(_rcAnimate); var prefixCls = 'ant-upload'; exports['default'] = _react2['default'].createClass({ displayName: 'uploadList', getDefaultProps: function getDefaultProps() { return { items: [] }; }, getInitialState: function getInitialState() { return { items: this.props.items }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { if ('items' in nextProps) { this.setState({ items: nextProps.items }); } }, handleClose: function handleClose(file) { this.props.onRemove(file); }, render: function render() { var _this = this; var list = this.state.items.map(function (file) { var statusIcon = file.status === 'done' ? _react2['default'].createElement('i', { className: 'anticon anticon-check ' + prefixCls + '-success-icon' }) : _react2['default'].createElement('i', { className: 'anticon anticon-loading' }); var filename = file.url ? _react2['default'].createElement( 'a', { className: prefixCls + '-item-name', href: file.url, target: '_blank' }, file.name ) : _react2['default'].createElement( 'b', { className: prefixCls + '-item-name' }, file.name ); return _react2['default'].createElement( 'div', { className: prefixCls + '-list-item', key: file.uid }, statusIcon, filename, _react2['default'].createElement('i', { className: 'anticon anticon-cross', ref: 'theCloseBtn', onClick: _this.handleClose.bind(_this, file) }) ); }); return _react2['default'].createElement( 'div', { className: prefixCls + '-list' }, _react2['default'].createElement( _rcAnimate2['default'], { transitionName: prefixCls + '-margin-top' }, list ) ); } }); module.exports = exports['default']; /***/ }, /* 352 */ /***/ function(module, exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports['default'] = getFileItem; function getFileItem(file, fileList) { var matchWay = !file.uid ? 'byName' : 'byUid'; var target = fileList.filter(function (item) { if (matchWay === 'byName') { return item.name === file.name; } else { return item.uid === file.uid; } })[0]; return target; } module.exports = exports['default']; /***/ }, /* 353 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; 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; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; 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 { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var prefixCls = 'ant-badge'; var AntBadge = (function (_React$Component) { _inherits(AntBadge, _React$Component); function AntBadge(props) { _classCallCheck(this, AntBadge); _get(Object.getPrototypeOf(AntBadge.prototype), 'constructor', this).call(this, props); this.state = { count: props.count }; } _createClass(AntBadge, [{ key: 'render', value: function render() { if (this.props.dot) { return _react2['default'].createElement( 'span', _extends({ className: prefixCls }, this.props), this.props.children, _react2['default'].createElement('sup', { className: prefixCls + '-dot' }) ); } var count = this.state.count; if (!count) { return (0, _react.cloneElement)(this.props.children); } else { count = count >= 100 ? '99+' : count; return _react2['default'].createElement( 'span', _extends({ className: prefixCls, title: this.state.count }, this.props), this.props.children, _react2['default'].createElement( 'sup', { className: prefixCls + '-count' }, count ) ); } } }]); return AntBadge; })(_react2['default'].Component); AntBadge.defaultProps = { prefixCls: prefixCls, count: null, dot: false }; AntBadge.propTypes = { count: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.string, _react2['default'].PropTypes.number]), dot: _react2['default'].PropTypes.bool }; exports['default'] = AntBadge; module.exports = exports['default']; /***/ }, /* 354 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); 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; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var _rcMenu = __webpack_require__(223); var _rcMenu2 = _interopRequireDefault(_rcMenu); var _commonOpenAnimation = __webpack_require__(340); var _commonOpenAnimation2 = _interopRequireDefault(_commonOpenAnimation); var AntMenu = _react2['default'].createClass({ displayName: 'AntMenu', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-menu' }; }, render: function render() { var openAnimation = ''; switch (this.props.mode) { case 'horizontal': openAnimation = 'slide-up'; break; case 'vertical': openAnimation = 'zoom-big'; break; case 'inline': openAnimation = _commonOpenAnimation2['default']; break; default: } if (this.props.mode === 'inline') { return _react2['default'].createElement(_rcMenu2['default'], _extends({}, this.props, { openAnimation: openAnimation })); } else { return _react2['default'].createElement(_rcMenu2['default'], _extends({}, this.props, { openTransitionName: openAnimation })); } } }); AntMenu.Divider = _rcMenu2['default'].Divider; AntMenu.Item = _rcMenu2['default'].Item; AntMenu.SubMenu = _rcMenu2['default'].SubMenu; exports['default'] = AntMenu; module.exports = exports['default']; /***/ }, /* 355 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _react = __webpack_require__(76); var _react2 = _interopRequireDefault(_react); var Timeline = _react2['default'].createClass({ displayName: 'Timeline', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-timeline' }; }, render: function render() { var children = this.props.children; return _react2['default'].createElement( 'ul', { className: this.props.prefixCls }, _react2['default'].Children.map(children, function (ele, idx) { var np = { timelineLast: idx === children.length - 1, pending: this.props.pending }; return _react2['default'].cloneElement(ele, np); }, this) ); } }); Timeline.Item = _react2['default'].createClass({ displayName: 'Item', getDefaultProps: function getDefaultProps() { return { prefixCls: 'ant-timeline', color: 'blue', pending: false }; }, render: function render() { var props = this.props; var prefixCls = props.prefixCls; var color = props.color; var pending = props.pending; var timelineLast = props.timelineLast; var endCls = pending && timelineLast ? prefixCls + '-item-last' : ''; var last = pending && timelineLast ? _react2['default'].createElement('div', { className: prefixCls + '-item-head ' + prefixCls + '-item-head-end' }) : null; var lastTailShow = timelineLast && !pending ? 'none' : 'block'; return _react2['default'].createElement( 'li', { className: prefixCls + '-item ' + endCls }, _react2['default'].createElement('div', { style: { display: lastTailShow }, className: prefixCls + '-item-tail' }), _react2['default'].createElement('div', { className: prefixCls + '-item-head ' + prefixCls + '-item-head-' + color }), _react2['default'].createElement( 'div', { className: prefixCls + '-item-content' }, props.children ), last ); } }); exports['default'] = Timeline; module.exports = exports['default']; /***/ }, /* 356 */ /***/ function(module, exports) { /* WEBPACK VAR INJECTION */(function(global) { /** * Module exports. */ module.exports = deprecate; /** * Mark that a method should not be used. * Returns a modified function which warns once by default. * * If `localStorage.noDeprecation = true` is set, then it is a no-op. * * If `localStorage.throwDeprecation = true` is set, then deprecated functions * will throw an Error when invoked. * * If `localStorage.traceDeprecation = true` is set, then deprecated functions * will invoke `console.trace()` instead of `console.error()`. * * @param {Function} fn - the function to deprecate * @param {String} msg - the string to print to the console when `fn` is invoked * @returns {Function} a new "deprecated" version of `fn` * @api public */ function deprecate (fn, msg) { if (config('noDeprecation')) { return fn; } var warned = false; function deprecated() { if (!warned) { if (config('throwDeprecation')) { throw new Error(msg); } else if (config('traceDeprecation')) { console.trace(msg); } else { console.warn(msg); } warned = true; } return fn.apply(this, arguments); } return deprecated; } /** * Checks `localStorage` for boolean values for the given `name`. * * @param {String} name * @returns {Boolean} * @api private */ function config (name) { // accessing global.localStorage can trigger a DOMException in sandboxed iframes try { if (!global.localStorage) return false; } catch (_) { return false; } var val = global.localStorage[name]; if (null == val) return false; return String(val).toLowerCase() === 'true'; } /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, /* 357 */ /***/ function(module, exports) { module.exports = { "name": "antd", "version": "0.9.2", "stableVersion": "0.9.2", "title": "Ant Design", "description": "一个 UI 设计语言", "homepage": "http://ant.design/", "keywords": [ "ant", "design", "react", "react-component", "component", "components", "ui", "framework", "frontend" ], "contributors": [ "ant" ], "repository": { "type": "git", "url": "https://github.com/ant-design/ant-design" }, "bugs": { "url": "https://github.com/ant-design/ant-design/issues" }, "main": "lib/index", "files": [ "lib" ], "license": "MIT", "dependencies": { "css-animation": "~1.1.0", "enter-animation": "~0.5.0", "gregorian-calendar": "~3.0.0", "gregorian-calendar-format": "~3.0.1", "object-assign": "~4.0.1", "rc-animate": "~1.2.9", "rc-calendar": "~3.16.1", "rc-checkbox": "~1.1.1", "rc-collapse": "~1.3.0", "rc-dialog": "~5.0.2", "rc-dropdown": "~1.3.3", "rc-form-validation": "~2.4.7", "rc-input-number": "~2.0.1", "rc-menu": "~4.6.0", "rc-notification": "~1.1.0", "rc-pagination": "~1.1.0", "rc-progress": "~1.0.0", "rc-radio": "~2.0.0", "rc-select": "~4.9.0", "rc-slider": "~1.4.0", "rc-steps": "~1.3.2", "rc-switch": "~1.2.0", "rc-table": "~3.2.0", "rc-tabs": "~5.3.2", "rc-tooltip": "~2.8.0", "rc-tree": "~0.15.4", "rc-upload": "~1.6.4", "rc-util": "~2.0.3", "react-slick": "~0.8.0", "reqwest-without-xhr2": "~2.0.2", "util-deprecate": "~1.0.1", "velocity-animate": "~1.2.2" }, "devDependencies": { "autoprefixer-loader": "^3.1.0", "babel": "^5.8.12", "babel-core": "^5.8.12", "babel-eslint": "^4.1.0", "babel-loader": "^5.3.2", "busboy": "^0.2.9", "chalk": "^1.1.0", "css-loader": "^0.14.1", "eslint": "^1.1.0", "eslint-config-airbnb": "^0.0.8", "eslint-plugin-babel": "^2.1.1", "eslint-plugin-react": "^3.3.1", "extract-text-webpack-plugin": "^0.8.1", "gh-pages": "^0.3.1", "json-loader": "^0.5.1", "less": "~2.5.1", "less-loader": "^2.2.0", "lesslint": "^0.1.7", "lodash": "^3.10.0", "nico-jsx": "~0.5.8", "precommit-hook": "^1.0.7", "react": "~0.13.0", "react-router": "1.0.0-rc1", "semver": "~5.0.3", "webpack": "^1.10.1", "webpack-dev-middleware": "^1.2.0" }, "scripts": { "babel": "babel components --out-dir lib", "release": "npm run clean && webpack --config webpack.config.production.js && webpack --config webpack.config.min.js && zip dist/${npm_package_name}-${npm_package_version}.zip -j dist dist/*", "start": "npm run clean && nico server --watch", "clean": "rm -rf _site dist", "deploy": "rm -rf node_modules && node scripts/install.js && npm run just-deploy", "just-deploy": "npm run clean && webpack && webpack --config webpack.config.min.js && NODE_ENV=PRODUCTION nico build && node scripts/deploy.js", "lint": "eslint components index.js --ext '.js,.jsx'", "lesslint": "lesslint style", "test": "webpack && npm run lint", "pub": "sh ./scripts/publish.sh", "beta": "sh ./scripts/publish.sh --tag beta" }, "precommit": [ "lint" ] }; /***/ } /******/ ]) }); ; //# sourceMappingURL=antd.js.map
| ver. 1.4 |
Github
|
.
| PHP 8.0.26 | Генераци� �траницы: 0.16 |
proxy
|
phpinfo
|
�а�тройка