analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
56 lines (51 loc) • 3.18 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
var _chunkWDPJM5OFjs = require('./chunk-WDPJM5OF.js');
// src/hooks/useTheme.ts
var _react = require('react');
var useTheme = () => {
const {
themeMode,
isDark,
toggleTheme,
setTheme,
initializeTheme,
handleSystemThemeChange
} = _chunkWDPJM5OFjs.useThemeStore.call(void 0, );
const branding = _react.useMemo.call(void 0, () => {
if (typeof document === "undefined") {
return {
theme: null,
favicon: null,
icon: null,
mainLogo: null,
internalLogo: null,
loginImage: null
};
}
return {
theme: _nullishCoalesce(_optionalChain([document, 'access', _ => _.querySelector, 'call', _2 => _2('meta[name="theme"]'), 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4("content")]), () => ( null)),
favicon: _nullishCoalesce(_optionalChain([document, 'access', _5 => _5.querySelector, 'call', _6 => _6('link[rel="icon"]'), 'optionalAccess', _7 => _7.getAttribute, 'call', _8 => _8("href")]), () => ( null)),
icon: _nullishCoalesce(_optionalChain([document, 'access', _9 => _9.querySelector, 'call', _10 => _10('link[rel="apple-touch-icon"]'), 'optionalAccess', _11 => _11.getAttribute, 'call', _12 => _12("href")]), () => ( null)),
mainLogo: _nullishCoalesce(_optionalChain([document, 'access', _13 => _13.querySelector, 'call', _14 => _14('meta[name="main-logo"]'), 'optionalAccess', _15 => _15.getAttribute, 'call', _16 => _16("content")]), () => ( null)),
internalLogo: _nullishCoalesce(_optionalChain([document, 'access', _17 => _17.querySelector, 'call', _18 => _18('meta[name="internal-logo"]'), 'optionalAccess', _19 => _19.getAttribute, 'call', _20 => _20("content")]), () => ( null)),
loginImage: _nullishCoalesce(_optionalChain([document, 'access', _21 => _21.querySelector, 'call', _22 => _22('meta[name="login-image"]'), 'optionalAccess', _23 => _23.getAttribute, 'call', _24 => _24("content")]), () => ( null))
};
}, []);
_react.useEffect.call(void 0, () => {
initializeTheme();
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
mediaQuery.addEventListener("change", handleSystemThemeChange);
return () => {
mediaQuery.removeEventListener("change", handleSystemThemeChange);
};
}, [initializeTheme, handleSystemThemeChange]);
return {
themeMode,
isDark,
toggleTheme,
setTheme,
branding
};
};
exports.useTheme = useTheme;
//# sourceMappingURL=chunk-ORRSVKFK.js.map