UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 2.15 kB
{"version":3,"file":"get-style.cjs","names":["resolveStyles","resolveStyle"],"sources":["../../../../../src/core/styles-api/use-styles/get-style/get-style.ts"],"sourcesContent":["import { CSSProperties } from 'react';\nimport { MantineTheme } from '../../../MantineProvider';\nimport { GetStylesApiOptions } from '../../styles-api.types';\nimport { resolveStyle } from './resolve-style/resolve-style';\nimport { resolveStyles } from './resolve-styles/resolve-styles';\n\nexport type _Styles =\n | undefined\n | Partial<Record<string, CSSProperties>>\n | ((\n theme: MantineTheme,\n props: Record<string, any>,\n ctx: Record<string, any> | undefined\n ) => Partial<Record<string, CSSProperties>>);\n\nexport interface GetStyleInput {\n theme: MantineTheme;\n selector: string;\n rootSelector: string;\n options: GetStylesApiOptions | undefined;\n props: Record<string, any>;\n stylesCtx: Record<string, any> | undefined;\n withStylesTransform?: boolean;\n resolvedStyles: Record<string, any>;\n resolvedThemeStyles: Record<string, any>;\n resolvedVars: Record<string, any>;\n resolvedRootStyle: CSSProperties;\n}\n\nexport function getStyle({\n theme,\n selector,\n options,\n props,\n stylesCtx,\n rootSelector,\n withStylesTransform,\n resolvedStyles,\n resolvedThemeStyles,\n resolvedVars,\n resolvedRootStyle,\n}: GetStyleInput): CSSProperties {\n return {\n ...resolvedThemeStyles[selector],\n ...resolvedStyles[selector],\n ...(!withStylesTransform &&\n resolveStyles({ theme, styles: options?.styles, props: options?.props || props, stylesCtx })[\n selector\n ]),\n ...resolvedVars[selector],\n ...(rootSelector === selector ? resolvedRootStyle : null),\n ...resolveStyle({ style: options?.style, theme }),\n };\n}\n"],"mappings":";;;;AA6BA,SAAgB,SAAS,EACvB,OACA,UACA,SACA,OACA,WACA,cACA,qBACA,gBACA,qBACA,cACA,qBAC+B;AAC/B,QAAO;EACL,GAAG,oBAAoB;EACvB,GAAG,eAAe;EAClB,GAAI,CAAC,uBACHA,uBAAAA,cAAc;GAAE;GAAO,QAAQ,SAAS;GAAQ,OAAO,SAAS,SAAS;GAAO;GAAW,CAAC,CAC1F;EAEJ,GAAG,aAAa;EAChB,GAAI,iBAAiB,WAAW,oBAAoB;EACpD,GAAGC,sBAAAA,aAAa;GAAE,OAAO,SAAS;GAAO;GAAO,CAAC;EAClD"}