ant-design-vue
Version:
An enterprise-class UI design language and Vue-based implementation
63 lines (53 loc) • 2.26 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _vue = require("vue");
var _vueTypes = _interopRequireDefault(require("../_util/vue-types"));
var _default2 = _interopRequireDefault(require("./default"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _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; }; return _extends.apply(this, arguments); }
var _default = (0, _vue.defineComponent)({
name: 'LocaleReceiver',
props: {
componentName: _vueTypes.default.string,
defaultLocale: {
type: [Object, Function]
},
children: {
type: Function
}
},
setup: function setup() {
return {
localeData: (0, _vue.inject)('localeData', {})
};
},
methods: {
getLocale: function getLocale() {
var _this$componentName = this.componentName,
componentName = _this$componentName === void 0 ? 'global' : _this$componentName,
defaultLocale = this.defaultLocale;
var locale = defaultLocale || _default2.default[componentName || 'global'];
var antLocale = this.localeData.antLocale;
var localeFromContext = componentName && antLocale ? antLocale[componentName] : {};
return _extends(_extends({}, typeof locale === 'function' ? locale() : locale), localeFromContext || {});
},
getLocaleCode: function getLocaleCode() {
var antLocale = this.localeData.antLocale;
var localeCode = antLocale && antLocale.locale; // Had use LocaleProvide but didn't set locale
if (antLocale && antLocale.exist && !localeCode) {
return _default2.default.locale;
}
return localeCode;
}
},
render: function render() {
var $slots = this.$slots;
var children = this.children || $slots.default;
var antLocale = this.localeData.antLocale;
return children === null || children === void 0 ? void 0 : children(this.getLocale(), this.getLocaleCode(), antLocale);
}
});
exports.default = _default;
;