tss-react-v18-peer-testing
Version:
makeStyles is dead, long live makeStyles!
65 lines (64 loc) • 3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TssCacheProvider = exports.useTssEmotionCache = exports.getTssDefaultEmotionCache = exports.getDoExistsTssDefaultEmotionCacheMemoizedValue = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const cache_1 = __importDefault(require("@emotion/cache"));
const { getDoExistsTssDefaultEmotionCacheMemoizedValue, getTssDefaultEmotionCache, reactContext, } = (() => {
const propertyKey = "__tss-react_context";
const peerDepObj =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
react_1.createContext;
let sharedContext = peerDepObj["__tss-react_context"];
if (sharedContext === undefined) {
const { getTssDefaultEmotionCache, getDoExistsTssDefaultEmotionCacheMemoizedValue, } = (() => {
let cache = undefined;
/**
* Lazily initialized singleton
* If doReset is set to true the memoized instance will be
* discarded and a new one created.
* */
function getTssDefaultEmotionCache(params) {
const { doReset = false } = params !== null && params !== void 0 ? params : {};
if (doReset) {
cache = undefined;
}
if (cache === undefined) {
cache = (0, cache_1.default)({ "key": "tss" });
}
return cache;
}
return {
getTssDefaultEmotionCache,
"getDoExistsTssDefaultEmotionCacheMemoizedValue": () => cache !== undefined,
};
})();
sharedContext = {
getTssDefaultEmotionCache,
getDoExistsTssDefaultEmotionCacheMemoizedValue,
"reactContext": (0, react_1.createContext)(undefined),
};
Object.defineProperty(peerDepObj, propertyKey, {
"configurable": false,
"enumerable": false,
"writable": false,
"value": sharedContext,
});
}
return sharedContext;
})();
exports.getDoExistsTssDefaultEmotionCacheMemoizedValue = getDoExistsTssDefaultEmotionCacheMemoizedValue;
exports.getTssDefaultEmotionCache = getTssDefaultEmotionCache;
function useTssEmotionCache() {
const cacheExplicitlyProvidedForTss = (0, react_1.useContext)(reactContext);
return cacheExplicitlyProvidedForTss !== null && cacheExplicitlyProvidedForTss !== void 0 ? cacheExplicitlyProvidedForTss : getTssDefaultEmotionCache();
}
exports.useTssEmotionCache = useTssEmotionCache;
function TssCacheProvider(props) {
const { children, value } = props;
return ((0, jsx_runtime_1.jsx)(reactContext.Provider, Object.assign({ value: value }, { children: children })));
}
exports.TssCacheProvider = TssCacheProvider;