|
1 | 1 | /* eslint-disable no-continue, no-loop-func, no-cond-assign */ |
| 2 | +import * as React from 'react' |
2 | 3 | import { Theme } from '@emotion/react' |
3 | 4 | import styled, { StyledComponent } from '@emotion/styled' |
4 | 5 | import { compose, StyleGenerator } from '@xstyled/system' |
5 | 6 |
|
6 | 7 | type JSXElementKeys = keyof JSX.IntrinsicElements |
7 | 8 |
|
8 | | -const tags = Object.keys(styled) |
9 | | - |
10 | | -export const createX = <TProps extends object>(generator: StyleGenerator) => { |
11 | | - type X<TProps extends object> = { |
12 | | - extend<TExtendProps extends object>( |
13 | | - ...generators: StyleGenerator[] |
14 | | - ): X<TExtendProps> |
15 | | - } & { |
16 | | - [Key in JSXElementKeys]: StyledComponent< |
17 | | - TProps & { as?: React.ElementType; theme?: Theme }, |
18 | | - JSX.IntrinsicElements[Key] |
19 | | - > |
20 | | - } |
| 9 | +type JSXElements<TProps> = { |
| 10 | + [Key in JSXElementKeys]: StyledComponent< |
| 11 | + TProps & { as?: React.ElementType; theme?: Theme }, |
| 12 | + JSX.IntrinsicElements[Key] |
| 13 | + > |
| 14 | +} |
| 15 | + |
| 16 | +type CreateX = <TProps extends object>(generator: StyleGenerator) => X<TProps> |
| 17 | + |
| 18 | +export interface X<TProps extends object> extends JSXElements<TProps> { |
| 19 | + extend: CreateX |
| 20 | +} |
| 21 | + |
| 22 | +const tags = Object.keys(styled) as JSXElementKeys[] |
21 | 23 |
|
| 24 | +export const createX: CreateX = <TProps extends object>( |
| 25 | + generator: StyleGenerator, |
| 26 | +) => { |
22 | 27 | // @ts-ignore |
23 | 28 | const x: X<TProps> = { |
24 | 29 | extend: (...generators) => createX(compose(generator, ...generators)), |
|
0 commit comments