Skip to content

Commit

Permalink
[@mantine/styles] Allow createStyle to go to the original definition (#…
Browse files Browse the repository at this point in the history
…3108)

* types: make createStyle go to original definition

* fix: fix the typings again
  • Loading branch information
imranbarbhuiya committed Dec 10, 2022
1 parent 3cf1e4d commit ecb4b15
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/mantine-styles/src/tss/create-styles.ts
Expand Up @@ -49,14 +49,14 @@ function getStyles<Key extends string>(
return extractStyles(styles);
}

export function createStyles<Key extends string = string, Params = void>(
export function createStyles<
Key extends string = string,
Params = void,
Input extends Record<Key, CSSObject> = Record<Key, CSSObject>
>(
input:
| ((
theme: MantineTheme,
params: Params,
createRef: (refName: string) => string
) => Record<Key, CSSObject>)
| Record<Key, CSSObject>
| ((theme: MantineTheme, params: Params, createRef: (refName: string) => string) => Input)
| Input
) {
const getCssObject = typeof input === 'function' ? input : () => input;

Expand All @@ -80,14 +80,18 @@ export function createStyles<Key extends string = string, Params = void>(
);
return [key, mergedStyles];
})
) as Record<Key, string>;
) as {
[key in keyof Input]: string;
};

return {
classes: mergeClassNames({
classes: mergeClassNames<{ [key in keyof Input]: string }>({
cx,
classes,
context,
classNames: options?.classNames,
classNames: options?.classNames as {
[key in keyof Input]: string;
},
name: options?.name,
cache,
}),
Expand Down

0 comments on commit ecb4b15

Please sign in to comment.