UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 1.06 kB
{"version":3,"file":"use-props.mjs","names":[],"sources":["../../../../src/core/MantineProvider/use-props/use-props.ts"],"sourcesContent":["import { filterProps } from '../../utils';\nimport { useMantineTheme } from '../MantineThemeProvider';\n\nexport function useProps<T extends Record<string, any>, U extends Partial<T> | null = {}>(\n component: string,\n defaultProps: U,\n props: T\n): T &\n (U extends null | undefined\n ? {}\n : {\n [Key in Extract<keyof T, keyof U>]-?: U[Key] | NonNullable<T[Key]>;\n }) {\n const theme = useMantineTheme();\n const contextPropsPayload = theme.components[component]?.defaultProps;\n const contextProps =\n typeof contextPropsPayload === 'function' ? contextPropsPayload(theme) : contextPropsPayload;\n\n return { ...defaultProps, ...contextProps, ...filterProps(props) };\n}\n"],"mappings":";;;;AAGA,SAAgB,SACd,WACA,cACA,OAMO;CACP,MAAM,QAAQ,iBAAiB;CAC/B,MAAM,sBAAsB,MAAM,WAAW,YAAY;CACzD,MAAM,eACJ,OAAO,wBAAwB,aAAa,oBAAoB,MAAM,GAAG;AAE3E,QAAO;EAAE,GAAG;EAAc,GAAG;EAAc,GAAG,YAAY,MAAM;EAAE"}