katoikia-app/web-ui/web-react/node_modules/.cache/babel-loader/8f2a73817d33ea8e552b1643ecc...

1 line
68 KiB
JSON
Raw Normal View History

2022-07-06 04:15:11 +00:00
{"ast":null,"code":"import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { createMemoryHistory, createLocation, locationsAreEqual, createPath } from 'history';\nimport warning from 'tiny-warning';\nimport createContext from 'mini-create-react-context';\nimport invariant from 'tiny-invariant';\nimport _extends from '@babel/runtime/helpers/esm/extends';\nimport pathToRegexp from 'path-to-regexp';\nimport { isValidElementType } from 'react-is';\nimport _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';\nimport hoistStatics from 'hoist-non-react-statics'; // TODO: Replace with React.createContext once we can assume React 16+\n\nvar createNamedContext = function createNamedContext(name) {\n var context = createContext();\n context.displayName = name;\n return context;\n};\n\nvar historyContext = /*#__PURE__*/createNamedContext(\"Router-History\");\nvar context = /*#__PURE__*/createNamedContext(\"Router\");\n/**\n * The public API for putting history on context.\n */\n\nvar Router = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(Router, _React$Component);\n\n Router.computeRootMatch = function computeRootMatch(pathname) {\n return {\n path: \"/\",\n url: \"/\",\n params: {},\n isExact: pathname === \"/\"\n };\n };\n\n function Router(props) {\n var _this;\n\n _this = _React$Component.call(this, props) || this;\n _this.state = {\n location: props.history.location\n }; // This is a bit of a hack. We have to start listening for location\n // changes here in the constructor in case there are any <Redirect>s\n // on the initial render. If there are, they will replace/push when\n // they mount and since cDM fires in children before parents, we may\n // get a new location before the <Router> is mounted.\n\n _this._isMounted = false;\n _this._pendingLocation = null;\n\n if (!props.staticContext) {\n _this.unlisten = props.history.listen(function (location) {\n _this._pendingLocation = location;\n });\n }\n\n return _this;\n }\n\n var _proto = Router.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n var _this2 = this;\n\n this._isMounted = true;\n\n if (this.unlisten) {\n // Any pre-mount location changes have been captured at\n // this point, so unregister the listener.\n this.unlisten();\n }\n\n if (!this.props.staticContext) {\n this.unlisten = this.props.history.listen(function (location) {\n if (_this2._isMounted) {\n _this2.setState({\n location: location\n });\n }\n });\n }\n\n if (this._pendingLocation) {\n this.setState({\n location: this._pendingLocation\n });\n }\n };\n\n _proto.componentWillUnmount = function componentWillUnmount() {\n if (this.unlisten) {\n this.unlisten();\n this._isMounted = false;\n this._pendingLocation = null;\n }\n };\n\n _proto.render = function render() {\n return /*#__PURE__*/React.createElement(context.Provider, {\n value: {\n history: this.props.history,\n location: this.state.location,\n match: Router.computeRootMatch(this.state.location.pathname),\n staticContext: this.props.staticContext\n }\n }, /*#__PURE__*/React.createElement(historyContext.Provider, {\n children: this.props.children || null,\n value: this.props.history\n }));\n };\n\n return Router;\n}(React.Component);\n\nif (process.env.NODE_ENV !== \"production\") {\n Router.propTypes = {\n children: PropTypes.node,\n history: PropTypes.object.isRequired,\n staticContext: PropTypes.object\n };\n\n Router.prototype.componentDidUpdate = function (prevProps) {\n process.env.NODE_ENV !== \"production\" ? warning(prevProps.history === this.props.history, \"You cannot change <Router history>\") : void 0;\n };\n}\n/**\n * The public API for a <Router> that stores location