devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
85 lines (82 loc) • 2.72 kB
JavaScript
/**
* DevExtreme (renovation/common/config_provider.js)
* Version: 24.2.6
* Build date: Mon Mar 17 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
exports.viewFunction = exports.ConfigProviderProps = exports.ConfigProvider = void 0;
var _inferno = require("@devextreme/runtime/inferno");
var _config_context = require("../../__internal/core/r1/config_context");
const _excluded = ["children", "rtlEnabled"];
function _objectWithoutPropertiesLoose(r, e) {
if (null == r) {
return {}
}
var t = {};
for (var n in r) {
if ({}.hasOwnProperty.call(r, n)) {
if (e.includes(n)) {
continue
}
t[n] = r[n]
}
}
return t
}
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function(n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) {
({}).hasOwnProperty.call(t, r) && (n[r] = t[r])
}
}
return n
}, _extends.apply(null, arguments)
}
const viewFunction = viewModel => viewModel.props.children;
exports.viewFunction = viewFunction;
const ConfigProviderProps = exports.ConfigProviderProps = {};
class ConfigProvider extends _inferno.BaseInfernoComponent {
constructor(props) {
super(props);
this.state = {};
this.__getterCache = {}
}
getChildContext() {
return _extends({}, this.context, {
[_config_context.ConfigContext.id]: this.config || _config_context.ConfigContext.defaultValue
})
}
get config() {
if (void 0 !== this.__getterCache.config) {
return this.__getterCache.config
}
return this.__getterCache.config = (() => ({
rtlEnabled: this.props.rtlEnabled
}))()
}
get restAttributes() {
const _this$props = this.props,
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
return restProps
}
componentWillUpdate(nextProps, nextState, context) {
if (this.props.rtlEnabled !== nextProps.rtlEnabled) {
this.__getterCache.config = void 0
}
}
render() {
const props = this.props;
return viewFunction({
props: _extends({}, props),
config: this.config,
restAttributes: this.restAttributes
})
}
}
exports.ConfigProvider = ConfigProvider;
ConfigProvider.defaultProps = ConfigProviderProps;