GoScrobble/web/node_modules/@material-ui/styles/ServerStyleSheets/ServerStyleSheets.js

66 lines
2.2 KiB
JavaScript
Raw Normal View History

2022-04-25 02:47:15 +00:00
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _react = _interopRequireDefault(require("react"));
var _jss = require("jss");
var _StylesProvider = _interopRequireDefault(require("../StylesProvider"));
var _createGenerateClassName = _interopRequireDefault(require("../createGenerateClassName"));
var ServerStyleSheets = /*#__PURE__*/function () {
function ServerStyleSheets() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck2.default)(this, ServerStyleSheets);
this.options = options;
}
(0, _createClass2.default)(ServerStyleSheets, [{
key: "collect",
value: function collect(children) {
// This is needed in order to deduplicate the injection of CSS in the page.
var sheetsManager = new Map(); // This is needed in order to inject the critical CSS.
this.sheetsRegistry = new _jss.SheetsRegistry(); // A new class name generator
var generateClassName = (0, _createGenerateClassName.default)();
return /*#__PURE__*/_react.default.createElement(_StylesProvider.default, (0, _extends2.default)({
sheetsManager: sheetsManager,
serverGenerateClassName: generateClassName,
sheetsRegistry: this.sheetsRegistry
}, this.options), children);
}
}, {
key: "toString",
value: function toString() {
return this.sheetsRegistry ? this.sheetsRegistry.toString() : '';
}
}, {
key: "getStyleElement",
value: function getStyleElement(props) {
return /*#__PURE__*/_react.default.createElement('style', (0, _extends2.default)({
id: 'jss-server-side',
key: 'jss-server-side',
dangerouslySetInnerHTML: {
__html: this.toString()
}
}, props));
}
}]);
return ServerStyleSheets;
}();
exports.default = ServerStyleSheets;