@douyinfe/semi-ui
Version:
A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.
62 lines (61 loc) • 2.16 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.ConfigConsumer = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _constants = require("@douyinfe/semi-foundation/lib/cjs/base/constants");
var _zh_CN = _interopRequireDefault(require("../locale/source/zh_CN"));
var _context = _interopRequireDefault(require("./context"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var __rest = void 0 && (void 0).__rest || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
const ConfigConsumer = exports.ConfigConsumer = _context.default.Consumer;
class ConfigProvider extends _react.default.Component {
constructor(props) {
super(props);
}
renderChildren() {
const {
direction,
children
} = this.props;
if (direction === 'rtl') {
return /*#__PURE__*/_react.default.createElement("div", {
className: `${_constants.BASE_CLASS_PREFIX}-rtl`
}, children);
}
return children;
}
render() {
const _a = this.props,
{
children,
direction
} = _a,
rest = __rest(_a, ["children", "direction"]);
return /*#__PURE__*/_react.default.createElement(_context.default.Provider, {
value: Object.assign({
direction
}, rest)
}, this.renderChildren());
}
}
exports.default = ConfigProvider;
ConfigProvider.propTypes = {
locale: _propTypes.default.object,
timeZone: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
getPopupContainer: _propTypes.default.func,
direction: _propTypes.default.oneOf(['ltr', 'rtl'])
};
ConfigProvider.defaultProps = {
locale: _zh_CN.default,
direction: 'ltr'
};
;