import _extends from"babel-runtime/helpers/extends";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";import*as React from"react";import*as PropTypes from"prop-types";import*as moment from"moment";import{changeConfirmLocale}from"../modal/locale";function setMomentLocale(e){e&&e.locale?moment.locale(e.locale):moment.locale("zh-cn")}var LocaleProvider=function(e){function o(){return _classCallCheck(this,o),_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).apply(this,arguments))}return _inherits(o,e),_createClass(o,[{key:"getChildContext",value:function(){return{antLocale:_extends({},this.props.locale,{exist:!0})}}},{key:"componentWillMount",value:function(){setMomentLocale(this.props.locale),this.componentDidUpdate()}},{key:"componentWillReceiveProps",value:function(e){this.props.locale!==e.locale&&setMomentLocale(e.locale)}},{key:"componentDidUpdate",value:function(){var e=this.props.locale;changeConfirmLocale(e&&e.Modal)}},{key:"componentWillUnmount",value:function(){changeConfirmLocale()}},{key:"render",value:function(){return React.Children.only(this.props.children)}}]),o}(React.Component);export default LocaleProvider;LocaleProvider.propTypes={locale:PropTypes.object},LocaleProvider.defaultProps={locale:{}},LocaleProvider.childContextTypes={antLocale:PropTypes.object};