worked on GarageApp stuff
This commit is contained in:
parent
60aaf17af3
commit
eb606572b0
51919 changed files with 2168177 additions and 18 deletions
229
node_modules/@emotion/styled/src/base.tsx
generated
vendored
Normal file
229
node_modules/@emotion/styled/src/base.tsx
generated
vendored
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
import isBrowser from '#is-browser'
|
||||
import isDevelopment from '#is-development'
|
||||
import { Theme, ThemeContext, withEmotionCache } from '@emotion/react'
|
||||
import { Interpolation, serializeStyles } from '@emotion/serialize'
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks'
|
||||
import {
|
||||
EmotionCache,
|
||||
getRegisteredStyles,
|
||||
insertStyles,
|
||||
registerStyles,
|
||||
SerializedStyles
|
||||
} from '@emotion/utils'
|
||||
import * as React from 'react'
|
||||
import { CreateStyled, ElementType, StyledOptions } from './types'
|
||||
import { composeShouldForwardProps, getDefaultShouldForwardProp } from './utils'
|
||||
export type {
|
||||
ArrayInterpolation,
|
||||
ComponentSelector,
|
||||
CSSObject,
|
||||
FunctionInterpolation,
|
||||
Interpolation
|
||||
} from '@emotion/serialize'
|
||||
|
||||
const ILLEGAL_ESCAPE_SEQUENCE_ERROR = `You have illegal escape sequence in your template literal, most likely inside content's property value.
|
||||
Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example "content: '\\00d7';" should become "content: '\\\\00d7';".
|
||||
You can read more about this here:
|
||||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences`
|
||||
|
||||
const Insertion = ({
|
||||
cache,
|
||||
serialized,
|
||||
isStringTag
|
||||
}: {
|
||||
cache: EmotionCache
|
||||
serialized: SerializedStyles
|
||||
isStringTag: boolean
|
||||
}) => {
|
||||
registerStyles(cache, serialized, isStringTag)
|
||||
|
||||
const rules = useInsertionEffectAlwaysWithSyncFallback(() =>
|
||||
insertStyles(cache, serialized, isStringTag)
|
||||
)
|
||||
|
||||
if (!isBrowser && rules !== undefined) {
|
||||
let serializedNames = serialized.name
|
||||
let next = serialized.next
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name
|
||||
next = next.next
|
||||
}
|
||||
return (
|
||||
<style
|
||||
{...{
|
||||
[`data-emotion`]: `${cache.key} ${serializedNames}`,
|
||||
dangerouslySetInnerHTML: { __html: rules },
|
||||
nonce: cache.sheet.nonce
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const createStyled = (tag: ElementType, options?: StyledOptions) => {
|
||||
if (isDevelopment) {
|
||||
if (tag === undefined) {
|
||||
throw new Error(
|
||||
'You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.'
|
||||
)
|
||||
}
|
||||
}
|
||||
const isReal = tag.__emotion_real === tag
|
||||
const baseTag = (isReal && tag.__emotion_base) || tag
|
||||
|
||||
let identifierName: string | undefined
|
||||
let targetClassName: string | undefined
|
||||
if (options !== undefined) {
|
||||
identifierName = options.label
|
||||
targetClassName = options.target
|
||||
}
|
||||
|
||||
const shouldForwardProp = composeShouldForwardProps(tag, options, isReal)
|
||||
const defaultShouldForwardProp =
|
||||
shouldForwardProp || getDefaultShouldForwardProp(baseTag)
|
||||
const shouldUseAs = !defaultShouldForwardProp('as')
|
||||
|
||||
return function () {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
let args = arguments as any as Array<
|
||||
TemplateStringsArray | Interpolation<Theme>
|
||||
>
|
||||
let styles =
|
||||
isReal && tag.__emotion_styles !== undefined
|
||||
? tag.__emotion_styles.slice(0)
|
||||
: []
|
||||
|
||||
if (identifierName !== undefined) {
|
||||
styles.push(`label:${identifierName};`)
|
||||
}
|
||||
if (
|
||||
args[0] == null ||
|
||||
(args[0] as TemplateStringsArray).raw === undefined
|
||||
) {
|
||||
// eslint-disable-next-line prefer-spread
|
||||
styles.push.apply(styles, args)
|
||||
} else {
|
||||
const templateStringsArr = args[0] as TemplateStringsArray
|
||||
if (isDevelopment && templateStringsArr[0] === undefined) {
|
||||
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR)
|
||||
}
|
||||
styles.push(templateStringsArr[0])
|
||||
let len = args.length
|
||||
let i = 1
|
||||
for (; i < len; i++) {
|
||||
if (isDevelopment && templateStringsArr[i] === undefined) {
|
||||
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR)
|
||||
}
|
||||
styles.push(args[i], templateStringsArr[i])
|
||||
}
|
||||
}
|
||||
|
||||
const Styled: ElementType = withEmotionCache(
|
||||
(props: Record<string, unknown>, cache, ref) => {
|
||||
const FinalTag =
|
||||
(shouldUseAs && (props.as as React.ElementType)) || baseTag
|
||||
|
||||
let className = ''
|
||||
let classInterpolations: Interpolation<Theme>[] = []
|
||||
let mergedProps = props
|
||||
if (props.theme == null) {
|
||||
mergedProps = {}
|
||||
for (let key in props) {
|
||||
mergedProps[key] = props[key]
|
||||
}
|
||||
mergedProps.theme = React.useContext(ThemeContext)
|
||||
}
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = getRegisteredStyles(
|
||||
cache.registered,
|
||||
classInterpolations,
|
||||
props.className
|
||||
)
|
||||
} else if (props.className != null) {
|
||||
className = `${props.className} `
|
||||
}
|
||||
|
||||
const serialized = serializeStyles(
|
||||
styles.concat(classInterpolations),
|
||||
cache.registered,
|
||||
mergedProps
|
||||
)
|
||||
className += `${cache.key}-${serialized.name}`
|
||||
if (targetClassName !== undefined) {
|
||||
className += ` ${targetClassName}`
|
||||
}
|
||||
|
||||
const finalShouldForwardProp =
|
||||
shouldUseAs && shouldForwardProp === undefined
|
||||
? getDefaultShouldForwardProp(FinalTag)
|
||||
: defaultShouldForwardProp
|
||||
|
||||
let newProps: Record<string, unknown> = {}
|
||||
|
||||
for (let key in props) {
|
||||
if (shouldUseAs && key === 'as') continue
|
||||
|
||||
if (finalShouldForwardProp(key)) {
|
||||
newProps[key] = props[key]
|
||||
}
|
||||
}
|
||||
newProps.className = className
|
||||
if (ref) {
|
||||
newProps.ref = ref
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Insertion
|
||||
cache={cache}
|
||||
serialized={serialized}
|
||||
isStringTag={typeof FinalTag === 'string'}
|
||||
/>
|
||||
<FinalTag {...newProps} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
Styled.displayName =
|
||||
identifierName !== undefined
|
||||
? identifierName
|
||||
: `Styled(${
|
||||
typeof baseTag === 'string'
|
||||
? baseTag
|
||||
: baseTag.displayName || baseTag.name || 'Component'
|
||||
})`
|
||||
|
||||
Styled.defaultProps = tag.defaultProps
|
||||
Styled.__emotion_real = Styled
|
||||
Styled.__emotion_base = baseTag
|
||||
Styled.__emotion_styles = styles
|
||||
Styled.__emotion_forwardProp = shouldForwardProp
|
||||
|
||||
Object.defineProperty(Styled, 'toString', {
|
||||
value() {
|
||||
if (targetClassName === undefined && isDevelopment) {
|
||||
return 'NO_COMPONENT_SELECTOR'
|
||||
}
|
||||
return `.${targetClassName}`
|
||||
}
|
||||
})
|
||||
;(Styled as any).withComponent = (
|
||||
nextTag: ElementType,
|
||||
nextOptions: StyledOptions
|
||||
) => {
|
||||
const newStyled = createStyled(nextTag, {
|
||||
...options,
|
||||
...nextOptions,
|
||||
shouldForwardProp: composeShouldForwardProps(Styled, nextOptions, true)
|
||||
})
|
||||
return (newStyled as any)(...styles)
|
||||
}
|
||||
|
||||
return Styled
|
||||
}
|
||||
}
|
||||
|
||||
export default createStyled as CreateStyled
|
||||
1
node_modules/@emotion/styled/src/conditions/false.ts
generated
vendored
Normal file
1
node_modules/@emotion/styled/src/conditions/false.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export default false
|
||||
1
node_modules/@emotion/styled/src/conditions/is-browser.ts
generated
vendored
Normal file
1
node_modules/@emotion/styled/src/conditions/is-browser.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export default typeof document !== 'undefined'
|
||||
1
node_modules/@emotion/styled/src/conditions/true.ts
generated
vendored
Normal file
1
node_modules/@emotion/styled/src/conditions/true.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export default true
|
||||
42
node_modules/@emotion/styled/src/index.ts
generated
vendored
Normal file
42
node_modules/@emotion/styled/src/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { Theme } from '@emotion/react'
|
||||
import baseStyled from './base'
|
||||
import { ReactJSXIntrinsicElements } from './jsx-namespace'
|
||||
import { tags } from './tags'
|
||||
import {
|
||||
CreateStyledComponent,
|
||||
CreateStyled as BaseCreateStyled
|
||||
} from './types'
|
||||
export type {
|
||||
ArrayInterpolation,
|
||||
ComponentSelector,
|
||||
CSSObject,
|
||||
FunctionInterpolation,
|
||||
Interpolation
|
||||
} from '@emotion/serialize'
|
||||
export type {
|
||||
CreateStyledComponent,
|
||||
FilteringStyledOptions,
|
||||
StyledComponent,
|
||||
StyledOptions
|
||||
} from './types'
|
||||
|
||||
export type StyledTags = {
|
||||
[Tag in keyof ReactJSXIntrinsicElements]: CreateStyledComponent<
|
||||
{
|
||||
theme?: Theme
|
||||
as?: React.ElementType
|
||||
},
|
||||
ReactJSXIntrinsicElements[Tag]
|
||||
>
|
||||
}
|
||||
|
||||
export interface CreateStyled extends BaseCreateStyled, StyledTags {}
|
||||
|
||||
// bind it to avoid mutating the original function
|
||||
const styled = baseStyled.bind(null) as CreateStyled
|
||||
|
||||
tags.forEach(tagName => {
|
||||
;(styled as any)[tagName] = styled(tagName as keyof typeof styled)
|
||||
})
|
||||
|
||||
export default styled
|
||||
12
node_modules/@emotion/styled/src/jsx-namespace.ts
generated
vendored
Normal file
12
node_modules/@emotion/styled/src/jsx-namespace.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// this is basically a slimmed down copy of https://github.com/emotion-js/emotion/blob/main/packages/react/types/jsx-namespace.d.ts
|
||||
// it helps to avoid issues when combining newer `@emotion/styled` and older `@emotion/react` versions
|
||||
// in such setup, ReactJSX namespace won't exist in `@emotion/react` and that would lead to errors
|
||||
import 'react'
|
||||
|
||||
type IsPreReact19 = 2 extends Parameters<React.FunctionComponent<any>>['length']
|
||||
? true
|
||||
: false
|
||||
|
||||
// prettier-ignore
|
||||
/** @ts-ignore */
|
||||
export type ReactJSXIntrinsicElements = true extends IsPreReact19 ? JSX.IntrinsicElements : React.JSX.IntrinsicElements
|
||||
138
node_modules/@emotion/styled/src/tags.ts
generated
vendored
Normal file
138
node_modules/@emotion/styled/src/tags.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
export const tags = [
|
||||
'a',
|
||||
'abbr',
|
||||
'address',
|
||||
'area',
|
||||
'article',
|
||||
'aside',
|
||||
'audio',
|
||||
'b',
|
||||
'base',
|
||||
'bdi',
|
||||
'bdo',
|
||||
'big',
|
||||
'blockquote',
|
||||
'body',
|
||||
'br',
|
||||
'button',
|
||||
'canvas',
|
||||
'caption',
|
||||
'cite',
|
||||
'code',
|
||||
'col',
|
||||
'colgroup',
|
||||
'data',
|
||||
'datalist',
|
||||
'dd',
|
||||
'del',
|
||||
'details',
|
||||
'dfn',
|
||||
'dialog',
|
||||
'div',
|
||||
'dl',
|
||||
'dt',
|
||||
'em',
|
||||
'embed',
|
||||
'fieldset',
|
||||
'figcaption',
|
||||
'figure',
|
||||
'footer',
|
||||
'form',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'head',
|
||||
'header',
|
||||
'hgroup',
|
||||
'hr',
|
||||
'html',
|
||||
'i',
|
||||
'iframe',
|
||||
'img',
|
||||
'input',
|
||||
'ins',
|
||||
'kbd',
|
||||
'keygen',
|
||||
'label',
|
||||
'legend',
|
||||
'li',
|
||||
'link',
|
||||
'main',
|
||||
'map',
|
||||
'mark',
|
||||
'marquee',
|
||||
'menu',
|
||||
'menuitem',
|
||||
'meta',
|
||||
'meter',
|
||||
'nav',
|
||||
'noscript',
|
||||
'object',
|
||||
'ol',
|
||||
'optgroup',
|
||||
'option',
|
||||
'output',
|
||||
'p',
|
||||
'param',
|
||||
'picture',
|
||||
'pre',
|
||||
'progress',
|
||||
'q',
|
||||
'rp',
|
||||
'rt',
|
||||
'ruby',
|
||||
's',
|
||||
'samp',
|
||||
'script',
|
||||
'section',
|
||||
'select',
|
||||
'small',
|
||||
'source',
|
||||
'span',
|
||||
'strong',
|
||||
'style',
|
||||
'sub',
|
||||
'summary',
|
||||
'sup',
|
||||
'table',
|
||||
'tbody',
|
||||
'td',
|
||||
'textarea',
|
||||
'tfoot',
|
||||
'th',
|
||||
'thead',
|
||||
'time',
|
||||
'title',
|
||||
'tr',
|
||||
'track',
|
||||
'u',
|
||||
'ul',
|
||||
'var',
|
||||
'video',
|
||||
'wbr',
|
||||
|
||||
// SVG
|
||||
'circle',
|
||||
'clipPath',
|
||||
'defs',
|
||||
'ellipse',
|
||||
'foreignObject',
|
||||
'g',
|
||||
'image',
|
||||
'line',
|
||||
'linearGradient',
|
||||
'mask',
|
||||
'path',
|
||||
'pattern',
|
||||
'polygon',
|
||||
'polyline',
|
||||
'radialGradient',
|
||||
'rect',
|
||||
'stop',
|
||||
'svg',
|
||||
'text',
|
||||
'tspan'
|
||||
] as const
|
||||
190
node_modules/@emotion/styled/src/types.ts
generated
vendored
Normal file
190
node_modules/@emotion/styled/src/types.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
import { ComponentSelector, Interpolation } from '@emotion/serialize'
|
||||
import { ReactJSXIntrinsicElements } from './jsx-namespace'
|
||||
import { PropsOf, Theme } from '@emotion/react'
|
||||
|
||||
/** Same as StyledOptions but shouldForwardProp must be a type guard */
|
||||
export interface FilteringStyledOptions<
|
||||
Props = Record<string, any>,
|
||||
ForwardedProps extends keyof Props & string = keyof Props & string
|
||||
> {
|
||||
label?: string
|
||||
shouldForwardProp?: (propName: string) => propName is ForwardedProps
|
||||
target?: string
|
||||
}
|
||||
|
||||
export interface StyledOptions<Props = Record<string, any>> {
|
||||
label?: string
|
||||
shouldForwardProp?: (propName: string) => boolean
|
||||
target?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @typeparam ComponentProps Props which will be included when withComponent is called
|
||||
* @typeparam SpecificComponentProps Props which will *not* be included when withComponent is called
|
||||
*/
|
||||
export interface StyledComponent<
|
||||
ComponentProps extends {},
|
||||
SpecificComponentProps extends {} = {},
|
||||
JSXProps extends {} = {}
|
||||
> extends React.FC<ComponentProps & SpecificComponentProps & JSXProps>,
|
||||
ComponentSelector {
|
||||
withComponent<C extends React.ComponentClass<React.ComponentProps<C>>>(
|
||||
component: C
|
||||
): StyledComponent<
|
||||
ComponentProps & PropsOf<C>,
|
||||
{},
|
||||
{ ref?: React.Ref<InstanceType<C>> }
|
||||
>
|
||||
withComponent<C extends React.ComponentType<React.ComponentProps<C>>>(
|
||||
component: C
|
||||
): StyledComponent<ComponentProps & PropsOf<C>>
|
||||
withComponent<Tag extends keyof ReactJSXIntrinsicElements>(
|
||||
tag: Tag
|
||||
): StyledComponent<ComponentProps, ReactJSXIntrinsicElements[Tag]>
|
||||
}
|
||||
|
||||
/**
|
||||
* @typeparam ComponentProps Props which will be included when withComponent is called
|
||||
* @typeparam SpecificComponentProps Props which will *not* be included when withComponent is called
|
||||
*/
|
||||
export interface CreateStyledComponent<
|
||||
ComponentProps extends {},
|
||||
SpecificComponentProps extends {} = {},
|
||||
JSXProps extends {} = {}
|
||||
> {
|
||||
(
|
||||
template: TemplateStringsArray,
|
||||
...styles: Array<
|
||||
Interpolation<ComponentProps & SpecificComponentProps & { theme: Theme }>
|
||||
>
|
||||
): StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>
|
||||
|
||||
/**
|
||||
* @typeparam AdditionalProps Additional props to add to your styled component
|
||||
*/
|
||||
<AdditionalProps extends {}>(
|
||||
template: TemplateStringsArray,
|
||||
...styles: Array<
|
||||
Interpolation<
|
||||
ComponentProps &
|
||||
SpecificComponentProps &
|
||||
AdditionalProps & { theme: Theme }
|
||||
>
|
||||
>
|
||||
): StyledComponent<
|
||||
ComponentProps & AdditionalProps,
|
||||
SpecificComponentProps,
|
||||
JSXProps
|
||||
>
|
||||
|
||||
/**
|
||||
* @typeparam AdditionalProps Additional props to add to your styled component
|
||||
*/
|
||||
<AdditionalProps extends {} = {}>(
|
||||
...styles: Array<
|
||||
Interpolation<
|
||||
ComponentProps &
|
||||
SpecificComponentProps &
|
||||
AdditionalProps & { theme: Theme }
|
||||
>
|
||||
>
|
||||
): StyledComponent<
|
||||
ComponentProps & AdditionalProps,
|
||||
SpecificComponentProps,
|
||||
JSXProps
|
||||
>
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc
|
||||
* This function accepts a React component or tag ('div', 'a' etc).
|
||||
*
|
||||
* @example styled(MyComponent)({ width: 100 })
|
||||
* @example styled(MyComponent)(myComponentProps => ({ width: myComponentProps.width })
|
||||
* @example styled('div')({ width: 100 })
|
||||
* @example styled('div')<Props>(props => ({ width: props.width })
|
||||
*/
|
||||
export interface CreateStyled {
|
||||
<
|
||||
C extends React.ComponentClass<React.ComponentProps<C>>,
|
||||
ForwardedProps extends keyof React.ComponentProps<C> &
|
||||
string = keyof React.ComponentProps<C> & string
|
||||
>(
|
||||
component: C,
|
||||
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
|
||||
): CreateStyledComponent<
|
||||
Pick<PropsOf<C>, ForwardedProps> & {
|
||||
theme?: Theme
|
||||
},
|
||||
{},
|
||||
{
|
||||
ref?: React.Ref<InstanceType<C>>
|
||||
}
|
||||
>
|
||||
|
||||
<C extends React.ComponentClass<React.ComponentProps<C>>>(
|
||||
component: C,
|
||||
options?: StyledOptions<React.ComponentProps<C>>
|
||||
): CreateStyledComponent<
|
||||
PropsOf<C> & {
|
||||
theme?: Theme
|
||||
},
|
||||
{},
|
||||
{
|
||||
ref?: React.Ref<InstanceType<C>>
|
||||
}
|
||||
>
|
||||
|
||||
<
|
||||
C extends React.ComponentType<React.ComponentProps<C>>,
|
||||
ForwardedProps extends keyof React.ComponentProps<C> &
|
||||
string = keyof React.ComponentProps<C> & string
|
||||
>(
|
||||
component: C,
|
||||
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
|
||||
): CreateStyledComponent<
|
||||
Pick<PropsOf<C>, ForwardedProps> & {
|
||||
theme?: Theme
|
||||
}
|
||||
>
|
||||
|
||||
<C extends React.ComponentType<React.ComponentProps<C>>>(
|
||||
component: C,
|
||||
options?: StyledOptions<React.ComponentProps<C>>
|
||||
): CreateStyledComponent<
|
||||
PropsOf<C> & {
|
||||
theme?: Theme
|
||||
}
|
||||
>
|
||||
|
||||
<
|
||||
Tag extends keyof ReactJSXIntrinsicElements,
|
||||
ForwardedProps extends keyof ReactJSXIntrinsicElements[Tag] &
|
||||
string = keyof ReactJSXIntrinsicElements[Tag] & string
|
||||
>(
|
||||
tag: Tag,
|
||||
options: FilteringStyledOptions<
|
||||
ReactJSXIntrinsicElements[Tag],
|
||||
ForwardedProps
|
||||
>
|
||||
): CreateStyledComponent<
|
||||
{ theme?: Theme; as?: React.ElementType },
|
||||
Pick<ReactJSXIntrinsicElements[Tag], ForwardedProps>
|
||||
>
|
||||
|
||||
<Tag extends keyof ReactJSXIntrinsicElements>(
|
||||
tag: Tag,
|
||||
options?: StyledOptions<ReactJSXIntrinsicElements[Tag]>
|
||||
): CreateStyledComponent<
|
||||
{ theme?: Theme; as?: React.ElementType },
|
||||
ReactJSXIntrinsicElements[Tag]
|
||||
>
|
||||
}
|
||||
|
||||
export type ElementType = React.ElementType & {
|
||||
defaultProps?: Partial<any>
|
||||
__emotion_real?: ElementType
|
||||
__emotion_base?: ElementType
|
||||
__emotion_styles?: Interpolation<Theme>[]
|
||||
__emotion_forwardProp?: (propName: string) => boolean
|
||||
}
|
||||
38
node_modules/@emotion/styled/src/utils.ts
generated
vendored
Normal file
38
node_modules/@emotion/styled/src/utils.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import * as React from 'react'
|
||||
import isPropValid from '@emotion/is-prop-valid'
|
||||
import { StyledOptions, ElementType } from './types'
|
||||
|
||||
const testOmitPropsOnStringTag = isPropValid
|
||||
const testOmitPropsOnComponent = (key: string) => key !== 'theme'
|
||||
|
||||
export const getDefaultShouldForwardProp = (tag: React.ElementType) =>
|
||||
typeof tag === 'string' &&
|
||||
// 96 is one less than the char code
|
||||
// for "a" so this is checking that
|
||||
// it's a lowercase character
|
||||
tag.charCodeAt(0) > 96
|
||||
? testOmitPropsOnStringTag
|
||||
: testOmitPropsOnComponent
|
||||
|
||||
export const composeShouldForwardProps = (
|
||||
tag: ElementType,
|
||||
options: StyledOptions | undefined,
|
||||
isReal: boolean
|
||||
) => {
|
||||
let shouldForwardProp
|
||||
if (options) {
|
||||
const optionsShouldForwardProp = options.shouldForwardProp
|
||||
shouldForwardProp =
|
||||
tag.__emotion_forwardProp && optionsShouldForwardProp
|
||||
? (propName: string) =>
|
||||
tag.__emotion_forwardProp!(propName) &&
|
||||
optionsShouldForwardProp(propName)
|
||||
: optionsShouldForwardProp
|
||||
}
|
||||
|
||||
if (typeof shouldForwardProp !== 'function' && isReal) {
|
||||
shouldForwardProp = tag.__emotion_forwardProp
|
||||
}
|
||||
|
||||
return shouldForwardProp
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue