MCPcopy Index your code
hub / github.com/microsoft/SandDance / withResponsiveMode

Function withResponsiveMode

docs/app/js/sanddance-app.js:31100–31136  ·  view source on GitHub ↗
(ComposedComponent)

Source from the content-addressed store, hash-verified

31098 return _a = _defaultMode !== null && _defaultMode !== void 0 ? _defaultMode : _lastMode, _a !== null && _a !== void 0 ? _a : ResponsiveMode.large;
31099}
31100function withResponsiveMode(ComposedComponent) {
31101 var _a;
31102 var resultClass = (_a = /** @class */ function(_super) {
31103 (0, _tslib.__extends)(WithResponsiveMode, _super);
31104 function WithResponsiveMode(props) {
31105 var _this = _super.call(this, props) || this;
31106 _this._onResize = function() {
31107 var responsiveMode = getResponsiveMode(_this.context.window);
31108 if (responsiveMode !== _this.state.responsiveMode) _this.setState({
31109 responsiveMode: responsiveMode
31110 });
31111 };
31112 _this._events = new (0, _utilities.EventGroup)(_this);
31113 _this._updateComposedComponentRef = _this._updateComposedComponentRef.bind(_this);
31114 _this.state = {
31115 responsiveMode: getInitialResponsiveMode()
31116 };
31117 return _this;
31118 }
31119 WithResponsiveMode.prototype.componentDidMount = function() {
31120 this._events.on(this.context.window, "resize", this._onResize);
31121 this._onResize();
31122 };
31123 WithResponsiveMode.prototype.componentWillUnmount = function() {
31124 this._events.dispose();
31125 };
31126 WithResponsiveMode.prototype.render = function() {
31127 var responsiveMode = this.state.responsiveMode;
31128 return responsiveMode === ResponsiveMode.unknown ? null : _react.createElement(ComposedComponent, (0, _tslib.__assign)({
31129 ref: this._updateComposedComponentRef,
31130 responsiveMode: responsiveMode
31131 }, this.props));
31132 };
31133 return WithResponsiveMode;
31134 }((0, _baseDecorator.BaseDecorator)), _a.contextType = (0, _windowProvider.WindowContext), _a);
31135 return (0, _utilities.hoistStatics)(ComposedComponent, resultClass);
31136}
31137function getWidthOfCurrentWindow(currentWindow) {
31138 try {
31139 return currentWindow.document.documentElement.clientWidth;

Callers

nothing calls this directly

Calls 1

onMethod · 0.45

Tested by

no test coverage detected