@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 1.55 kB
Source Map (JSON)
{"version":3,"file":"use-transformed-styles.mjs","names":[],"sources":["../../../../src/core/styles-api/use-styles/use-transformed-styles.ts"],"sourcesContent":["import { MantineTheme, useMantineStylesTransform } from '../../MantineProvider';\n\ninterface UseTransformedStylesInput {\n props: Record<string, any>;\n stylesCtx: Record<string, any> | undefined;\n themeName: string[];\n theme: MantineTheme;\n}\n\nexport function useStylesTransform({\n props,\n stylesCtx,\n themeName,\n theme,\n}: UseTransformedStylesInput) {\n const stylesTransform = useMantineStylesTransform()?.();\n\n const getTransformedStyles = (styles: any[]) => {\n if (!stylesTransform) {\n return [];\n }\n\n const transformedStyles = styles.map((style) =>\n stylesTransform(style, { props, theme, ctx: stylesCtx })\n );\n\n return [\n ...transformedStyles,\n ...themeName.map((n) =>\n stylesTransform(theme.components[n]?.styles, { props, theme, ctx: stylesCtx })\n ),\n ].filter(Boolean) as Record<string, string>[];\n };\n\n return {\n getTransformedStyles,\n withStylesTransform: !!stylesTransform,\n };\n}\n"],"mappings":";;;AASA,SAAgB,mBAAmB,EACjC,OACA,WACA,WACA,SAC4B;CAC5B,MAAM,kBAAkB,2BAA2B,IAAI;CAEvD,MAAM,wBAAwB,WAAkB;AAC9C,MAAI,CAAC,gBACH,QAAO,EAAE;AAOX,SAAO,CACL,GALwB,OAAO,KAAK,UACpC,gBAAgB,OAAO;GAAE;GAAO;GAAO,KAAK;GAAW,CAAC,CACzD,EAIC,GAAG,UAAU,KAAK,MAChB,gBAAgB,MAAM,WAAW,IAAI,QAAQ;GAAE;GAAO;GAAO,KAAK;GAAW,CAAC,CAC/E,CACF,CAAC,OAAO,QAAQ;;AAGnB,QAAO;EACL;EACA,qBAAqB,CAAC,CAAC;EACxB"}