@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 1.32 kB
Source Map (JSON)
{"version":3,"file":"hash-styles.cjs","names":["cssObjectToString"],"sources":["../../../src/core/InlineStyles/hash-styles.ts"],"sourcesContent":["import { cssObjectToString } from './css-object-to-string/css-object-to-string';\nimport type { InlineStylesMediaQuery } from './styles-to-string/styles-to-string';\n\nfunction djb2Hash(str: string): string {\n let hash = 5381;\n for (let i = 0; i < str.length; i++) {\n hash = ((hash << 5) + hash + str.charCodeAt(i)) & 0xffffffff;\n }\n return (hash >>> 0).toString(36);\n}\n\nexport function hashStyleProps(\n styles: React.CSSProperties | undefined,\n media: InlineStylesMediaQuery[] | undefined\n): string {\n const stylesStr = styles ? cssObjectToString(styles) : '';\n const mediaStr = Array.isArray(media)\n ? media.map((m) => `${m.query}:${cssObjectToString(m.styles)}`).join('|')\n : '';\n return `__mdi__-${djb2Hash(`${stylesStr}|${mediaStr}`)}`;\n}\n"],"mappings":";;;AAGA,SAAS,SAAS,KAAqB;CACrC,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAC9B,QAAS,QAAQ,KAAK,OAAO,IAAI,WAAW,CAAC,IAAK;CAEpD,QAAQ,SAAS,GAAG,SAAS,EAAE;AACjC;AAEA,SAAgB,eACd,QACA,OACQ;CAKR,OAAO,WAAW,SAAS,GAJT,SAASA,6BAAAA,kBAAkB,MAAM,IAAI,GAIf,GAHvB,MAAM,QAAQ,KAAK,IAChC,MAAM,KAAK,MAAM,GAAG,EAAE,MAAM,GAAGA,6BAAAA,kBAAkB,EAAE,MAAM,GAAG,EAAE,KAAK,GAAG,IACtE,IACiD;AACvD"}