@gdjiami/jm-mrc-components
Version:
移动端可复用组件库
25 lines (24 loc) • 1.06 kB
JavaScript
import { __assign } from "tslib";
import React, { createContext } from 'react';
export var Context = createContext({
getPrefixCls: function (suffixCls, customizePrefixCls) {
if (customizePrefixCls)
return customizePrefixCls;
return "jm-" + suffixCls;
},
});
export var ConfigConsumer = Context.Consumer;
var Provider = function (props) {
var getPrefixCls = function (suffixCls, customizePrefixCls) {
var _a = props.prefixCls, prefixCls = _a === void 0 ? 'jm' : _a;
if (customizePrefixCls)
return customizePrefixCls;
return suffixCls ? prefixCls + "-" + suffixCls : prefixCls;
};
var renderProvider = function (context) {
var config = __assign(__assign({}, context), { getPrefixCls: getPrefixCls, autoInsertSpaceInButton: props.autoInsertSpaceInButton });
return React.createElement(Context.Provider, { value: config }, props.children);
};
return React.createElement(ConfigConsumer, null, renderProvider);
};
export default Provider;