iobroker.vis-2
Version:
Next generation graphical user interface for ioBroker.
280 lines (279 loc) • 8.48 kB
JavaScript
import { e as __mf_15, n as __mf_28, _ as __mf_24, R as React, h as __mf_32, o as __mf_21, m as __mf_10, i as __mf_20, k as __mf_29, __tla as __tla_0 } from "./iobroker_vis__loadShare__react__loadShare__.js-Bo2lxMHB.js";
import { __tla as __tla_1 } from "./iobroker_vis__loadShare__prop_mf_2_types__loadShare__.js-OoAqYupB.js";
import { j as jsxRuntimeExports, __tla as __tla_2 } from "./jsx-runtime-DgDbgMDY.js";
import { T as ThemeContext, k as createTheme, m as defaultSxConfig, r as resolveProps, __tla as __tla_3 } from "./createStyled-BvULSPVR.js";
import { i as isPlainObject, __tla as __tla_4 } from "./clsx-XqGtd7JN.js";
let RtlProvider, useEnhancedEffect, useId, useThemeProps, unstable_createUseMediaQuery, extendSxProp, useTheme, getThemeProps, useTheme$1, isMuiElement, useMediaQuery, useRtl;
let __tla = Promise.all([
(() => {
try {
return __tla_0;
} catch {
}
})(),
(() => {
try {
return __tla_1;
} catch {
}
})(),
(() => {
try {
return __tla_2;
} catch {
}
})(),
(() => {
try {
return __tla_3;
} catch {
}
})(),
(() => {
try {
return __tla_4;
} catch {
}
})()
]).then(async () => {
isMuiElement = function(element, muiNames) {
var _a, _b, _c;
return __mf_15(element) && muiNames.indexOf(element.type.muiName ?? ((_c = (_b = (_a = element.type) == null ? void 0 : _a._payload) == null ? void 0 : _b.value) == null ? void 0 : _c.muiName)) !== -1;
};
useEnhancedEffect = typeof window !== "undefined" ? __mf_28 : __mf_24;
let globalId = 0;
function useGlobalId(idOverride) {
const [defaultId, setDefaultId] = __mf_32(idOverride);
const id = idOverride || defaultId;
__mf_24(() => {
if (defaultId == null) {
globalId += 1;
setDefaultId(`mui-${globalId}`);
}
}, [
defaultId
]);
return id;
}
const safeReact$1 = {
...React
};
const maybeReactUseId = safeReact$1.useId;
useId = function(idOverride) {
if (maybeReactUseId !== void 0) {
const reactId = maybeReactUseId();
return idOverride ?? reactId;
}
return useGlobalId(idOverride);
};
function isObjectEmpty(obj) {
return Object.keys(obj).length === 0;
}
useTheme$1 = function(defaultTheme = null) {
const contextTheme = __mf_21(ThemeContext);
return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
};
const RtlContext = __mf_10();
RtlProvider = function({ value, ...props }) {
return jsxRuntimeExports.jsx(RtlContext.Provider, {
value: value ?? true,
...props
});
};
useRtl = () => {
const value = __mf_21(RtlContext);
return value ?? false;
};
const systemDefaultTheme = createTheme();
useTheme = function(defaultTheme = systemDefaultTheme) {
return useTheme$1(defaultTheme);
};
const splitProps = (props) => {
var _a;
const result = {
systemProps: {},
otherProps: {}
};
const config = ((_a = props == null ? void 0 : props.theme) == null ? void 0 : _a.unstable_sxConfig) ?? defaultSxConfig;
Object.keys(props).forEach((prop) => {
if (config[prop]) {
result.systemProps[prop] = props[prop];
} else {
result.otherProps[prop] = props[prop];
}
});
return result;
};
extendSxProp = function(props) {
const { sx: inSx, ...other } = props;
const { systemProps, otherProps } = splitProps(other);
let finalSx;
if (Array.isArray(inSx)) {
finalSx = [
systemProps,
...inSx
];
} else if (typeof inSx === "function") {
finalSx = (...args) => {
const result = inSx(...args);
if (!isPlainObject(result)) {
return systemProps;
}
return {
...systemProps,
...result
};
};
} else {
finalSx = {
...systemProps,
...inSx
};
}
return {
...otherProps,
sx: finalSx
};
};
getThemeProps = function(params) {
const { theme, name, props } = params;
if (!theme || !theme.components || !theme.components[name] || !theme.components[name].defaultProps) {
return props;
}
return resolveProps(theme.components[name].defaultProps, props);
};
useThemeProps = function({ props, name, defaultTheme, themeId }) {
let theme = useTheme(defaultTheme);
if (themeId) {
theme = theme[themeId] || theme;
}
return getThemeProps({
theme,
name,
props
});
};
function useMediaQueryOld(query, defaultMatches, matchMedia, ssrMatchMedia, noSsr) {
const [match, setMatch] = __mf_32(() => {
if (noSsr && matchMedia) {
return matchMedia(query).matches;
}
if (ssrMatchMedia) {
return ssrMatchMedia(query).matches;
}
return defaultMatches;
});
useEnhancedEffect(() => {
if (!matchMedia) {
return void 0;
}
const queryList = matchMedia(query);
const updateMatch = () => {
setMatch(queryList.matches);
};
updateMatch();
queryList.addEventListener("change", updateMatch);
return () => {
queryList.removeEventListener("change", updateMatch);
};
}, [
query,
matchMedia
]);
return match;
}
const safeReact = {
...React
};
const maybeReactUseSyncExternalStore = safeReact.useSyncExternalStore;
function useMediaQueryNew(query, defaultMatches, matchMedia, ssrMatchMedia, noSsr) {
const getDefaultSnapshot = __mf_20(() => defaultMatches, [
defaultMatches
]);
const getServerSnapshot = __mf_29(() => {
if (noSsr && matchMedia) {
return () => matchMedia(query).matches;
}
if (ssrMatchMedia !== null) {
const { matches } = ssrMatchMedia(query);
return () => matches;
}
return getDefaultSnapshot;
}, [
getDefaultSnapshot,
query,
ssrMatchMedia,
noSsr,
matchMedia
]);
const [getSnapshot, subscribe] = __mf_29(() => {
if (matchMedia === null) {
return [
getDefaultSnapshot,
() => () => {
}
];
}
const mediaQueryList = matchMedia(query);
return [
() => mediaQueryList.matches,
(notify) => {
mediaQueryList.addEventListener("change", notify);
return () => {
mediaQueryList.removeEventListener("change", notify);
};
}
];
}, [
getDefaultSnapshot,
matchMedia,
query
]);
const match = maybeReactUseSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
return match;
}
unstable_createUseMediaQuery = function(params = {}) {
const { themeId } = params;
return function useMediaQuery2(queryInput, options = {}) {
let theme = useTheme$1();
if (theme && themeId) {
theme = theme[themeId] || theme;
}
const supportMatchMedia = typeof window !== "undefined" && typeof window.matchMedia !== "undefined";
const { defaultMatches = false, matchMedia = supportMatchMedia ? window.matchMedia : null, ssrMatchMedia = null, noSsr = false } = getThemeProps({
name: "MuiUseMediaQuery",
props: options,
theme
});
let query = typeof queryInput === "function" ? queryInput(theme) : queryInput;
query = query.replace(/^@media( ?)/m, "");
if (query.includes("print")) {
console.warn([
`MUI: You have provided a \`print\` query to the \`useMediaQuery\` hook.`,
"Using the print media query to modify print styles can lead to unexpected results.",
"Consider using the `displayPrint` field in the `sx` prop instead.",
"More information about `displayPrint` on our docs: https://mui.com/system/display/#display-in-print."
].join("\n"));
}
const useMediaQueryImplementation = maybeReactUseSyncExternalStore !== void 0 ? useMediaQueryNew : useMediaQueryOld;
const match = useMediaQueryImplementation(query, defaultMatches, matchMedia, ssrMatchMedia, noSsr);
return match;
};
};
useMediaQuery = unstable_createUseMediaQuery();
});
export {
RtlProvider as R,
__tla,
useEnhancedEffect as a,
useId as b,
useThemeProps as c,
unstable_createUseMediaQuery as d,
extendSxProp as e,
useTheme as f,
getThemeProps as g,
useTheme$1 as h,
isMuiElement as i,
useMediaQuery as j,
useRtl as u
};