UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 1.1 kB
{"version":3,"file":"resolve-style.cjs","names":[],"sources":["../../../../../../src/core/styles-api/use-styles/get-style/resolve-style/resolve-style.ts"],"sourcesContent":["import { CSSProperties } from 'react';\nimport { MantineStyleProp } from '../../../../Box';\nimport { MantineTheme } from '../../../../MantineProvider';\n\ninterface ResolveStyleInput {\n style: MantineStyleProp | undefined;\n theme: MantineTheme;\n}\n\nexport function resolveStyle({ style, theme }: ResolveStyleInput): CSSProperties {\n if (Array.isArray(style)) {\n return style.reduce<Record<string, any>>(\n (acc, item) => ({ ...acc, ...resolveStyle({ style: item, theme }) }),\n {}\n );\n }\n\n if (typeof style === 'function') {\n return style(theme);\n }\n\n if (style == null) {\n return {};\n }\n\n return style;\n}\n"],"mappings":";;AASA,SAAgB,aAAa,EAAE,OAAO,SAA2C;CAC/E,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,QACV,KAAK,UAAU;EAAE,GAAG;EAAK,GAAG,aAAa;GAAE,OAAO;GAAM;EAAM,CAAC;CAAE,IAClE,CAAC,CACH;CAGF,IAAI,OAAO,UAAU,YACnB,OAAO,MAAM,KAAK;CAGpB,IAAI,SAAS,MACX,OAAO,CAAC;CAGV,OAAO;AACT"}