@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
29 lines (28 loc) • 970 B
JavaScript
"use client";
import { useMantineStyleNonce } from "../MantineProvider/Mantine.context.mjs";
import { stylesToString } from "./styles-to-string/styles-to-string.mjs";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/core/InlineStyles/InlineStyles.tsx
function simpleHash(str) {
let hash = 5381;
for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i) & 4294967295;
return (hash >>> 0).toString(36);
}
function InlineStyles({ deduplicate, ...props }) {
const nonce = useMantineStyleNonce();
const css = stylesToString(props);
if (deduplicate) return /* @__PURE__ */ jsx("style", {
href: `mantine-${simpleHash(css)}`,
precedence: "mantine",
nonce: nonce?.(),
children: css
});
return /* @__PURE__ */ jsx("style", {
"data-mantine-styles": "inline",
nonce: nonce?.(),
dangerouslySetInnerHTML: { __html: css }
});
}
//#endregion
export { InlineStyles };
//# sourceMappingURL=InlineStyles.mjs.map