UNPKG

react-slide-selector

Version:

react selector with the slide feather such as contact lists, address lists

1,488 lines (1,155 loc) 775 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react"), require("react-dom"), require("iscroll-react")); else if(typeof define === 'function' && define.amd) define(["react", "react-dom", "iscroll-react"], factory); else if(typeof exports === 'object') exports["react-slide-selector"] = factory(require("react"), require("react-dom"), require("iscroll-react")); else root["react-slide-selector"] = factory(root["react"], root["react-dom"], root["iscroll-react"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_66__) { 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__) { module.exports = __webpack_require__(1); /***/ }, /* 1 */ /***/ 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 _react = __webpack_require__(2); var _react2 = _interopRequireDefault(_react); var _reactDom = __webpack_require__(3); var _reactRouter = __webpack_require__(4); var _iscrollReact = __webpack_require__(66); var _iscrollReact2 = _interopRequireDefault(_iscrollReact); var _iscroll = __webpack_require__(67); var _iscroll2 = _interopRequireDefault(_iscroll); var _lodash = __webpack_require__(68); var _ = _interopRequireWildcard(_lodash); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 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; } /** * Created by lx on 30/6/2016. */ //import { connect } from 'react-redux' //import TitleBar from "../../product/components/TitleBar" //import {utils} from "../../../root/libs/utils" //import {setInsuredInfo, queryProCityAreaList, checkDistrictInsuranceState} from "../actions/index" var SlideSelect = function (_Component) { _inherits(SlideSelect, _Component); function SlideSelect(props) { _classCallCheck(this, SlideSelect); var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(SlideSelect).call(this, props)); _this.handleTouchMove = _this.handleTouchMove.bind(_this); _this.handleTouchTap = _this.handleTouchTap.bind(_this); _this.state = {}; return _this; } _createClass(SlideSelect, [{ key: 'renderList', value: function renderList() { var _this2 = this; var firstCaptiialRowStyle = { width: '100%', borderTop: '1px solid', borderBottom: '1px solid', background: '#eee', padding: '10px 0', margin: '5px 0' }; var array = [], keyIndex = 0, letterList = []; _.forEach(this.props.data.list, function (values, key) { letterList.push(_react2.default.createElement( 'li', { key: keyIndex++, className: 'letterBarItems', style: { height: '4%' } }, key )); array.push(_react2.default.createElement( 'dt', { key: keyIndex++, className: 'firstCapitialRow', style: firstCaptiialRowStyle }, key )); _.forEach(values, function (value) { array.push(_react2.default.createElement( 'dd', { className: 'selectItems', key: keyIndex++, style: { padding: '5px 10px' } }, value[_this2.props.data.show] )); }); }); return { letterList: letterList, addressList: array }; } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { this.renderList(); } //slide sidebar to local the element that equal to the sidebar element }, { key: 'handleTouchMove', value: function handleTouchMove(e) { e.preventDefault(); var titles = document.getElementsByClassName('firstCapitialRow'), letterBarItem = document.getElementsByClassName('letterBarItems')[0], letterBar = document.getElementsByClassName('letterBar')[0], nodeNum = titles.length, y = e.targetTouches[0].clientY, targetOffsetTop = parseFloat(getComputedStyle(letterBar).top), nodeHeight = parseFloat(getComputedStyle(letterBarItem).height), curNode = (parseInt(y) - targetOffsetTop) / nodeHeight; //console.log(y) if (curNode >= 0 && curNode < nodeNum) { //window.scrollTo(0, titles[Math.floor(curNode)].offsetTop) new _iscroll2.default('#wrapper').scrollTo(0, -titles[Math.floor(curNode)].offsetTop); } } }, { key: 'handleTouchTap', value: function handleTouchTap(e) { e.preventDefault(); var tar = e.target; if (tar.className === 'selectItems') { console.log(tar.innerHTML); //hashHistory.push(`/invest/confirmInsured/${tar.innerHTML}/address/holder`) } } }, { key: 'render', value: function render() { var letterBar = { listStyle: 'none', position: 'fixed', top: 0, bottom: 0, right: '10px' }; return _react2.default.createElement( 'div', null, _react2.default.createElement( _iscrollReact2.default, { iScroll: _iscroll2.default, onScrollStart: this.onScrollStart }, _react2.default.createElement( 'dl', { onTouchTap: this.handleTouchTap }, this.renderList().addressList ) ), _react2.default.createElement( 'ul', { id: 'wrapper', className: 'letterBar', onTouchMove: this.handleTouchMove, onTouchStart: this.handleTouchMove, style: letterBar }, this.renderList().letterList ) ); } }]); return SlideSelect; }(_react.Component); SlideSelect.defaultProps = { options: { mouseWheel: true, scrollbars: true } }; SlideSelect.PropTypes = { data: _react.PropTypes.object }; exports.default = SlideSelect; /***/ }, /* 2 */ /***/ function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_2__; /***/ }, /* 3 */ /***/ function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_3__; /***/ }, /* 4 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; exports.__esModule = true; exports.createMemoryHistory = exports.hashHistory = exports.browserHistory = exports.applyRouterMiddleware = exports.formatPattern = exports.useRouterHistory = exports.match = exports.routerShape = exports.locationShape = exports.PropTypes = exports.RoutingContext = exports.RouterContext = exports.createRoutes = exports.useRoutes = exports.RouteContext = exports.Lifecycle = exports.History = exports.Route = exports.Redirect = exports.IndexRoute = exports.IndexRedirect = exports.withRouter = exports.IndexLink = exports.Link = exports.Router = undefined; var _RouteUtils = __webpack_require__(5); Object.defineProperty(exports, 'createRoutes', { enumerable: true, get: function get() { return _RouteUtils.createRoutes; } }); var _PropTypes2 = __webpack_require__(9); Object.defineProperty(exports, 'locationShape', { enumerable: true, get: function get() { return _PropTypes2.locationShape; } }); Object.defineProperty(exports, 'routerShape', { enumerable: true, get: function get() { return _PropTypes2.routerShape; } }); var _PatternUtils = __webpack_require__(12); Object.defineProperty(exports, 'formatPattern', { enumerable: true, get: function get() { return _PatternUtils.formatPattern; } }); var _Router2 = __webpack_require__(14); var _Router3 = _interopRequireDefault(_Router2); var _Link2 = __webpack_require__(43); var _Link3 = _interopRequireDefault(_Link2); var _IndexLink2 = __webpack_require__(44); var _IndexLink3 = _interopRequireDefault(_IndexLink2); var _withRouter2 = __webpack_require__(45); var _withRouter3 = _interopRequireDefault(_withRouter2); var _IndexRedirect2 = __webpack_require__(47); var _IndexRedirect3 = _interopRequireDefault(_IndexRedirect2); var _IndexRoute2 = __webpack_require__(49); var _IndexRoute3 = _interopRequireDefault(_IndexRoute2); var _Redirect2 = __webpack_require__(48); var _Redirect3 = _interopRequireDefault(_Redirect2); var _Route2 = __webpack_require__(50); var _Route3 = _interopRequireDefault(_Route2); var _History2 = __webpack_require__(51); var _History3 = _interopRequireDefault(_History2); var _Lifecycle2 = __webpack_require__(52); var _Lifecycle3 = _interopRequireDefault(_Lifecycle2); var _RouteContext2 = __webpack_require__(53); var _RouteContext3 = _interopRequireDefault(_RouteContext2); var _useRoutes2 = __webpack_require__(54); var _useRoutes3 = _interopRequireDefault(_useRoutes2); var _RouterContext2 = __webpack_require__(40); var _RouterContext3 = _interopRequireDefault(_RouterContext2); var _RoutingContext2 = __webpack_require__(55); var _RoutingContext3 = _interopRequireDefault(_RoutingContext2); var _PropTypes3 = _interopRequireDefault(_PropTypes2); var _match2 = __webpack_require__(56); var _match3 = _interopRequireDefault(_match2); var _useRouterHistory2 = __webpack_require__(60); var _useRouterHistory3 = _interopRequireDefault(_useRouterHistory2); var _applyRouterMiddleware2 = __webpack_require__(61); var _applyRouterMiddleware3 = _interopRequireDefault(_applyRouterMiddleware2); var _browserHistory2 = __webpack_require__(62); var _browserHistory3 = _interopRequireDefault(_browserHistory2); var _hashHistory2 = __webpack_require__(65); var _hashHistory3 = _interopRequireDefault(_hashHistory2); var _createMemoryHistory2 = __webpack_require__(57); var _createMemoryHistory3 = _interopRequireDefault(_createMemoryHistory2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.Router = _Router3.default; /* components */ exports.Link = _Link3.default; exports.IndexLink = _IndexLink3.default; exports.withRouter = _withRouter3.default; /* components (configuration) */ exports.IndexRedirect = _IndexRedirect3.default; exports.IndexRoute = _IndexRoute3.default; exports.Redirect = _Redirect3.default; exports.Route = _Route3.default; /* mixins */ exports.History = _History3.default; exports.Lifecycle = _Lifecycle3.default; exports.RouteContext = _RouteContext3.default; /* utils */ exports.useRoutes = _useRoutes3.default; exports.RouterContext = _RouterContext3.default; exports.RoutingContext = _RoutingContext3.default; exports.PropTypes = _PropTypes3.default; exports.match = _match3.default; exports.useRouterHistory = _useRouterHistory3.default; exports.applyRouterMiddleware = _applyRouterMiddleware3.default; /* histories */ exports.browserHistory = _browserHistory3.default; exports.hashHistory = _hashHistory3.default; exports.createMemoryHistory = _createMemoryHistory3.default; /***/ }, /* 5 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; exports.__esModule = 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; }; exports.isReactChildren = isReactChildren; exports.createRouteFromReactElement = createRouteFromReactElement; exports.createRoutesFromReactChildren = createRoutesFromReactChildren; exports.createRoutes = createRoutes; var _react = __webpack_require__(2); var _react2 = _interopRequireDefault(_react); var _routerWarning = __webpack_require__(7); var _routerWarning2 = _interopRequireDefault(_routerWarning); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function isValidChild(object) { return object == null || _react2.default.isValidElement(object); } function isReactChildren(object) { return isValidChild(object) || Array.isArray(object) && object.every(isValidChild); } function checkPropTypes(componentName, propTypes, props) { componentName = componentName || 'UnknownComponent'; for (var propName in propTypes) { if (Object.prototype.hasOwnProperty.call(propTypes, propName)) { var error = propTypes[propName](props, propName, componentName); /* istanbul ignore if: error logging */ if (error instanceof Error) process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, error.message) : void 0; } } } function createRoute(defaultProps, props) { return _extends({}, defaultProps, props); } function createRouteFromReactElement(element) { var type = element.type; var route = createRoute(type.defaultProps, element.props); if (type.propTypes) checkPropTypes(type.displayName || type.name, type.propTypes, route); if (route.children) { var childRoutes = createRoutesFromReactChildren(route.children, route); if (childRoutes.length) route.childRoutes = childRoutes; delete route.children; } return route; } /** * Creates and returns a routes object from the given ReactChildren. JSX * provides a convenient way to visualize how routes in the hierarchy are * nested. * * import { Route, createRoutesFromReactChildren } from 'react-router' * * const routes = createRoutesFromReactChildren( * <Route component={App}> * <Route path="home" component={Dashboard}/> * <Route path="news" component={NewsFeed}/> * </Route> * ) * * Note: This method is automatically used when you provide <Route> children * to a <Router> component. */ function createRoutesFromReactChildren(children, parentRoute) { var routes = []; _react2.default.Children.forEach(children, function (element) { if (_react2.default.isValidElement(element)) { // Component classes may have a static create* method. if (element.type.createRouteFromReactElement) { var route = element.type.createRouteFromReactElement(element, parentRoute); if (route) routes.push(route); } else { routes.push(createRouteFromReactElement(element)); } } }); return routes; } /** * Creates and returns an array of routes from the given object which * may be a JSX route, a plain object route, or an array of either. */ function createRoutes(routes) { if (isReactChildren(routes)) { routes = createRoutesFromReactChildren(routes); } else if (routes && !Array.isArray(routes)) { routes = [routes]; } return routes; } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, /* 6 */ /***/ function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; (function () { try { cachedSetTimeout = setTimeout; } catch (e) { cachedSetTimeout = function () { throw new Error('setTimeout is not defined'); } } try { cachedClearTimeout = clearTimeout; } catch (e) { cachedClearTimeout = function () { throw new Error('clearTimeout is not defined'); } } } ()) var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = cachedSetTimeout(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; cachedClearTimeout(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) { cachedSetTimeout(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; }; /***/ }, /* 7 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; exports.__esModule = true; exports.default = routerWarning; exports._resetWarned = _resetWarned; var _warning = __webpack_require__(8); var _warning2 = _interopRequireDefault(_warning); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var warned = {}; function routerWarning(falseToWarn, message) { // Only issue deprecation warnings once. if (message.indexOf('deprecated') !== -1) { if (warned[message]) { return; } warned[message] = true; } message = '[react-router] ' + message; for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } _warning2.default.apply(undefined, [falseToWarn, message].concat(args)); } function _resetWarned() { warned = {}; } /***/ }, /* 8 */ /***/ 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__(6))) /***/ }, /* 9 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; exports.__esModule = true; exports.router = exports.routes = exports.route = exports.components = exports.component = exports.location = exports.history = exports.falsy = exports.locationShape = exports.routerShape = undefined; var _react = __webpack_require__(2); var _deprecateObjectProperties = __webpack_require__(10); var _deprecateObjectProperties2 = _interopRequireDefault(_deprecateObjectProperties); var _InternalPropTypes = __webpack_require__(11); var InternalPropTypes = _interopRequireWildcard(_InternalPropTypes); var _routerWarning = __webpack_require__(7); var _routerWarning2 = _interopRequireDefault(_routerWarning); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var func = _react.PropTypes.func; var object = _react.PropTypes.object; var shape = _react.PropTypes.shape; var string = _react.PropTypes.string; var routerShape = exports.routerShape = shape({ push: func.isRequired, replace: func.isRequired, go: func.isRequired, goBack: func.isRequired, goForward: func.isRequired, setRouteLeaveHook: func.isRequired, isActive: func.isRequired }); var locationShape = exports.locationShape = shape({ pathname: string.isRequired, search: string.isRequired, state: object, action: string.isRequired, key: string }); // Deprecated stuff below: var falsy = exports.falsy = InternalPropTypes.falsy; var history = exports.history = InternalPropTypes.history; var location = exports.location = locationShape; var component = exports.component = InternalPropTypes.component; var components = exports.components = InternalPropTypes.components; var route = exports.route = InternalPropTypes.route; var routes = exports.routes = InternalPropTypes.routes; var router = exports.router = routerShape; if (process.env.NODE_ENV !== 'production') { (function () { var deprecatePropType = function deprecatePropType(propType, message) { return function () { process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, message) : void 0; return propType.apply(undefined, arguments); }; }; var deprecateInternalPropType = function deprecateInternalPropType(propType) { return deprecatePropType(propType, 'This prop type is not intended for external use, and was previously exported by mistake. These internal prop types are deprecated for external use, and will be removed in a later version.'); }; var deprecateRenamedPropType = function deprecateRenamedPropType(propType, name) { return deprecatePropType(propType, 'The `' + name + '` prop type is now exported as `' + name + 'Shape` to avoid name conflicts. This export is deprecated and will be removed in a later version.'); }; exports.falsy = falsy = deprecateInternalPropType(falsy); exports.history = history = deprecateInternalPropType(history); exports.component = component = deprecateInternalPropType(component); exports.components = components = deprecateInternalPropType(components); exports.route = route = deprecateInternalPropType(route); exports.routes = routes = deprecateInternalPropType(routes); exports.location = location = deprecateRenamedPropType(location, 'location'); exports.router = router = deprecateRenamedPropType(router, 'router'); })(); } var defaultExport = { falsy: falsy, history: history, location: location, component: component, components: components, route: route, // For some reason, routes was never here. router: router }; if (process.env.NODE_ENV !== 'production') { defaultExport = (0, _deprecateObjectProperties2.default)(defaultExport, 'The default export from `react-router/lib/PropTypes` is deprecated. Please use the named exports instead.'); } exports.default = defaultExport; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, /* 10 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; exports.__esModule = true; exports.canUseMembrane = undefined; var _routerWarning = __webpack_require__(7); var _routerWarning2 = _interopRequireDefault(_routerWarning); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var canUseMembrane = exports.canUseMembrane = false; // No-op by default. var deprecateObjectProperties = function deprecateObjectProperties(object) { return object; }; if (process.env.NODE_ENV !== 'production') { try { if (Object.defineProperty({}, 'x', { get: function get() { return true; } }).x) { exports.canUseMembrane = canUseMembrane = true; } /* eslint-disable no-empty */ } catch (e) {} /* eslint-enable no-empty */ if (canUseMembrane) { deprecateObjectProperties = function deprecateObjectProperties(object, message) { // Wrap the deprecated object in a membrane to warn on property access. var membrane = {}; var _loop = function _loop(prop) { if (!Object.prototype.hasOwnProperty.call(object, prop)) { return 'continue'; } if (typeof object[prop] === 'function') { // Can't use fat arrow here because of use of arguments below. membrane[prop] = function () { process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, message) : void 0; return object[prop].apply(object, arguments); }; return 'continue'; } // These properties are non-enumerable to prevent React dev tools from // seeing them and causing spurious warnings when accessing them. In // principle this could be done with a proxy, but support for the // ownKeys trap on proxies is not universal, even among browsers that // otherwise support proxies. Object.defineProperty(membrane, prop, { get: function get() { process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, message) : void 0; return object[prop]; } }); }; for (var prop in object) { var _ret = _loop(prop); if (_ret === 'continue') continue; } return membrane; }; } } exports.default = deprecateObjectProperties; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, /* 11 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; exports.__esModule = true; exports.routes = exports.route = exports.components = exports.component = exports.history = undefined; exports.falsy = falsy; var _react = __webpack_require__(2); var func = _react.PropTypes.func; var object = _react.PropTypes.object; var arrayOf = _react.PropTypes.arrayOf; var oneOfType = _react.PropTypes.oneOfType; var element = _react.PropTypes.element; var shape = _react.PropTypes.shape; var string = _react.PropTypes.string; function falsy(props, propName, componentName) { if (props[propName]) return new Error('<' + componentName + '> should not have a "' + propName + '" prop'); } var history = exports.history = shape({ listen: func.isRequired, push: func.isRequired, replace: func.isRequired, go: func.isRequired, goBack: func.isRequired, goForward: func.isRequired }); var component = exports.component = oneOfType([func, string]); var components = exports.components = oneOfType([component, object]); var route = exports.route = oneOfType([object, element]); var routes = exports.routes = oneOfType([route, arrayOf(route)]); /***/ }, /* 12 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; exports.__esModule = true; exports.compilePattern = compilePattern; exports.matchPattern = matchPattern; exports.getParamNames = getParamNames; exports.getParams = getParams; exports.formatPattern = formatPattern; var _invariant = __webpack_require__(13); var _invariant2 = _interopRequireDefault(_invariant); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } function _compilePattern(pattern) { var regexpSource = ''; var paramNames = []; var tokens = []; var match = void 0, lastIndex = 0, matcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*\*|\*|\(|\)/g; while (match = matcher.exec(pattern)) { if (match.index !== lastIndex) { tokens.push(pattern.slice(lastIndex, match.index)); regexpSource += escapeRegExp(pattern.slice(lastIndex, match.index)); } if (match[1]) { regexpSource += '([^/]+)'; paramNames.push(match[1]); } else if (match[0] === '**') { regexpSource += '(.*)'; paramNames.push('splat'); } else if (match[0] === '*') { regexpSource += '(.*?)'; paramNames.push('splat'); } else if (match[0] === '(') { regexpSource += '(?:'; } else if (match[0] === ')') { regexpSource += ')?'; } tokens.push(match[0]); lastIndex = matcher.lastIndex; } if (lastIndex !== pattern.length) { tokens.push(pattern.slice(lastIndex, pattern.length)); regexpSource += escapeRegExp(pattern.slice(lastIndex, pattern.length)); } return { pattern: pattern, regexpSource: regexpSource, paramNames: paramNames, tokens: tokens }; } var CompiledPatternsCache = {}; function compilePattern(pattern) { if (!(pattern in CompiledPatternsCache)) CompiledPatternsCache[pattern] = _compilePattern(pattern); return CompiledPatternsCache[pattern]; } /** * Attempts to match a pattern on the given pathname. Patterns may use * the following special characters: * * - :paramName Matches a URL segment up to the next /, ?, or #. The * captured string is considered a "param" * - () Wraps a segment of the URL that is optional * - * Consumes (non-greedy) all characters up to the next * character in the pattern, or to the end of the URL if * there is none * - ** Consumes (greedy) all characters up to the next character * in the pattern, or to the end of the URL if there is none * * The function calls callback(error, matched) when finished. * The return value is an object with the following properties: * * - remainingPathname * - paramNames * - paramValues */ function matchPattern(pattern, pathname) { // Ensure pattern starts with leading slash for consistency with pathname. if (pattern.charAt(0) !== '/') { pattern = '/' + pattern; } var _compilePattern2 = compilePattern(pattern); var regexpSource = _compilePattern2.regexpSource; var paramNames = _compilePattern2.paramNames; var tokens = _compilePattern2.tokens; if (pattern.charAt(pattern.length - 1) !== '/') { regexpSource += '/?'; // Allow optional path separator at end. } // Special-case patterns like '*' for catch-all routes. if (tokens[tokens.length - 1] === '*') { regexpSource += '$'; } var match = pathname.match(new RegExp('^' + regexpSource, 'i')); if (match == null) { return null; } var matchedPath = match[0]; var remainingPathname = pathname.substr(matchedPath.length); if (remainingPathname) { // Require that the match ends at a path separator, if we didn't match // the full path, so any remaining pathname is a new path segment. if (matchedPath.charAt(matchedPath.length - 1) !== '/') { return null; } // If there is a remaining pathname, treat the path separator as part of // the remaining pathname for properly continuing the match. remainingPathname = '/' + remainingPathname; } return { remainingPathname: remainingPathname, paramNames: paramNames, paramValues: match.slice(1).map(function (v) { return v && decodeURIComponent(v); }) }; } function getParamNames(pattern) { return compilePattern(pattern).paramNames; } function getParams(pattern, pathname) { var match = matchPattern(pattern, pathname); if (!match) { return null; } var paramNames = match.paramNames; var paramValues = match.paramValues; var params = {}; paramNames.forEach(function (paramName, index) { params[paramName] = paramValues[index]; }); return params; } /** * Returns a version of the given pattern with params interpolated. Throws * if there is a dynamic segment of the pattern for which there is no param. */ function formatPattern(pattern, params) { params = params || {}; var _compilePattern3 = compilePattern(pattern); var tokens = _compilePattern3.tokens; var parenCount = 0, pathname = '', splatIndex = 0; var token = void 0, paramName = void 0, paramValue = void 0; for (var i = 0, len = tokens.length; i < len; ++i) { token = tokens[i]; if (token === '*' || token === '**') { paramValue = Array.isArray(params.splat) ? params.splat[splatIndex++] : params.splat; !(paramValue != null || parenCount > 0) ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'Missing splat #%s for path "%s"', splatIndex, pattern) : (0, _invariant2.default)(false) : void 0; if (paramValue != null) pathname += encodeURI(paramValue); } else if (token === '(') { parenCount += 1; } else if (token === ')') { parenCount -= 1; } else if (token.charAt(0) === ':') { paramName = token.substring(1); paramValue = params[paramName]; !(paramValue != null || parenCount > 0) ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'Missing "%s" parameter for path "%s"', paramName, pattern) : (0, _invariant2.default)(false) : void 0; if (paramValue != null) pathname += encodeURIComponent(paramValue); } else { pathname += token; } } return pathname.replace(/\/+/g, '/'); } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, /* 13 */ /***/ 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. */ 'use strict'; /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var invariant = function(condition, format, a, b, c, d, e, f) { if (process.env.NODE_ENV !== 'production') { if (format === undefined) { throw new Error('invariant requires an error message argument'); } } if (!condition) { var error; if (format === undefined) { error = new Error( 'Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.' ); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error( format.replace(/%s/g, function() { return args[argIndex++]; }) ); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } }; module.exports = invariant; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, /* 14 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; exports.__esModule = 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 _createHashHistory = __webpack_require__(15); var _createHashHistory2 = _interopRequireDefault(_createHashHistory); var _useQueries = __webpack_require__(30); var _useQueries2 = _interopRequireDefault(_useQueries); var _react = __webpack_require__(2); var _react2 = _interopRequireDefault(_react); var _createTransitionManager = __webpack_require__(33); var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); var _InternalPropTypes = __webpack_require__(11); var _RouterContext = __webpack_require__(40); var _RouterContext2 = _interopRequireDefault(_RouterContext); var _RouteUtils = __webpack_require__(5); var _RouterUtils = __webpack_require__(42); var _routerWarning = __webpack_require__(7); var _routerWarning2 = _interopRequireDefault(_routerWarning); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function isDeprecatedHistory(history) { return !history || !history.__v2_compatible__; } var _React$PropTypes = _react2.default.PropTypes; var func = _React$PropTypes.func; var object = _React$PropTypes.object; /** * A <Router> is a high-level API for automatically setting up * a router that renders a <RouterContext> with all the props * it needs each time the URL changes. */ var Router = _react2.default.createClass({ displayName: 'Router', propTypes: { history: object, children: _InternalPropTypes.routes, routes: _InternalPropTypes.routes, // alias for children render: func, createElement: func, onError: func, onUpdate: func, // PRIVATE: For client-side rehydration of server match. matchContext: object }, getDefaultProps: function getDefaultProps() { return { render: function render(props) { return _react2.default.createElement(_RouterContext2.default, props); } }; }, getInitialState: function getInitialState() { return { location: null, routes: null, params: null, components: null }; }, handleError: function handleError(error) { if (this.props.onError) { this.props.onError.call(this, error); } else { // Throw errors by default so we don't silently swallow them! throw error; // This error probably occurred in getChildRoutes or getComponents. } }, componentWillMount: function componentWillMount() { var _this = this; var _props = this.props; var parseQueryString = _props.parseQueryString; var stringifyQuery = _props.stringifyQuery; process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(!(parseQueryString || stringifyQuery), '`parseQueryString` and `stringifyQuery` are deprecated. Please create a custom history. http://tiny.cc/router-customquerystring') : void 0; var _createRouterObjects = this.createRouterObjects(); var history = _createRouterObjects.history; var transitionManager = _createRouterObjects.transitionManager; var router = _createRouterObjects.router; this._unlisten = transitionManager.listen(function (error, state) { if (error) { _this.handleError(error); } else { _this.setState(state, _this.props.onUpdate); } }); this.history = history; this.router = router; }, createRouterObjects: function createRouterObjects() { var matchContext = this.props.matchContext; if (matchContext) { return matchContext; } var history = this.props.history; var _props2 = this.props; var routes = _props2.routes; var children = _props2.children; if (isDeprecatedHistory(history)) { history = this.wrapDeprecatedHistory(history); } var transitionManager = (0, _createTransitionManager2.default)(history, (0, _RouteUtils.createRoutes)(routes || children)); var router = (0, _RouterUtils.createRouterObject)(history, transitionManager); var routingHistory = (0, _RouterUtils.createRoutingHistory)(history, transitionManager); return { history: routingHistory, transitionManager: transitionManager, router: router }; }, wrapDeprecatedHistory: function wrapDeprecatedHistory(history) { var _props3 = this.props; var parseQueryString = _props3.parseQueryString; var stringifyQuery = _props3.stringifyQuery; var createHistory = void 0; if (history) { process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, 'It appears you have provided a deprecated history object to `<Router/>`, please use a history provided by ' + 'React Router with `import { browserHistory } from \'react-router\'` or `import { hashHistory } from \'react-router\'`. ' + 'If you are using a custom history please create it with `useRouterHistory`, see http://tiny.cc/router-usinghistory for details.') : void 0; createHistory = function createHistory() { return history; }; } else { process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, '`Router` no longer defaults the history prop to hash history. Please use the `hashHistory` singleton instead. http://tiny.cc/router-defaulthistory') : void 0; createHistory = _createHashHistory2.default; } return (0, _useQueries2.default)(createHistory)({ parseQueryString: parseQueryString, stringifyQuery: stringifyQuery }); }, /* istanbul ignore next: sanity check */ componentWillReceiveProps: function componentWillReceiveProps(nextProps) { process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(nextProps.history === this.props.history, 'You cannot change <Router history>; it will be ignored') : void 0; process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)((nextProps.routes || nextProps.children) === (this.props.routes || this.props.children), 'You cannot change <Router routes>; it will be ignored') : void 0; }, componentWillUnmount: function componentWillUnmount() { if (this._unlisten) this._unlisten(); }, render: function render() { var _state = this.state; var location = _state.location; var routes = _state.routes; var params = _state.params; var components = _state.components; var _props4 = this.props; var createElement = _props4.createElement; var render = _props4.render; var props = _objectWithoutProperties(_props4, ['createElement', 'render']); if (location == null) return null; // Async match // Only forward non-Router-specific props to routing context, as those are // the only ones that might be custom routing context props. Object.keys(Router.propTypes).forEach(function (propType) { return delete props[propType]; }); return render(_extends({}, props, { history: this.history, router: this.router, location: location, routes: routes, params: params, components: components, createElement: createElement })); } }); exports.default = Router; module.expor