init
This commit is contained in:
2
mc_test/node_modules/@emotion/styled/src/base.d.ts
generated
vendored
Executable file
2
mc_test/node_modules/@emotion/styled/src/base.d.ts
generated
vendored
Executable file
@ -0,0 +1,2 @@
|
||||
export * from '../types/base'
|
||||
export { default } from '../types/base'
|
||||
218
mc_test/node_modules/@emotion/styled/src/base.js
generated
vendored
Executable file
218
mc_test/node_modules/@emotion/styled/src/base.js
generated
vendored
Executable file
@ -0,0 +1,218 @@
|
||||
// @flow
|
||||
import * as React from 'react'
|
||||
import {
|
||||
getDefaultShouldForwardProp,
|
||||
composeShouldForwardProps,
|
||||
type StyledOptions,
|
||||
type CreateStyled,
|
||||
type PrivateStyledComponent,
|
||||
type StyledElementType
|
||||
} from './utils'
|
||||
import { withEmotionCache, ThemeContext } from '@emotion/react'
|
||||
import {
|
||||
getRegisteredStyles,
|
||||
insertStyles,
|
||||
registerStyles
|
||||
} from '@emotion/utils'
|
||||
import { serializeStyles } from '@emotion/serialize'
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks'
|
||||
|
||||
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`
|
||||
|
||||
let isBrowser = typeof document !== 'undefined'
|
||||
|
||||
const Insertion = ({ cache, serialized, isStringTag }) => {
|
||||
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
|
||||
}
|
||||
|
||||
let createStyled: CreateStyled = (tag: any, options?: StyledOptions) => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
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
|
||||
let targetClassName
|
||||
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 <Props>(): PrivateStyledComponent<Props> {
|
||||
let args = arguments
|
||||
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].raw === undefined) {
|
||||
styles.push.apply(styles, args)
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && args[0][0] === undefined) {
|
||||
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR)
|
||||
}
|
||||
styles.push(args[0][0])
|
||||
let len = args.length
|
||||
let i = 1
|
||||
for (; i < len; i++) {
|
||||
if (process.env.NODE_ENV !== 'production' && args[0][i] === undefined) {
|
||||
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR)
|
||||
}
|
||||
styles.push(args[i], args[0][i])
|
||||
}
|
||||
}
|
||||
|
||||
// $FlowFixMe: we need to cast StatelessFunctionalComponent to our PrivateStyledComponent class
|
||||
const Styled: PrivateStyledComponent<Props> = withEmotionCache(
|
||||
(props, cache, ref) => {
|
||||
const FinalTag = (shouldUseAs && props.as) || baseTag
|
||||
|
||||
let className = ''
|
||||
let classInterpolations = []
|
||||
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 = {}
|
||||
|
||||
for (let key in props) {
|
||||
if (shouldUseAs && key === 'as') continue
|
||||
|
||||
if (
|
||||
// $FlowFixMe
|
||||
finalShouldForwardProp(key)
|
||||
) {
|
||||
newProps[key] = props[key]
|
||||
}
|
||||
}
|
||||
|
||||
newProps.className = className
|
||||
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 &&
|
||||
process.env.NODE_ENV !== 'production'
|
||||
) {
|
||||
return 'NO_COMPONENT_SELECTOR'
|
||||
}
|
||||
// $FlowFixMe: coerce undefined to string
|
||||
return `.${targetClassName}`
|
||||
}
|
||||
})
|
||||
|
||||
Styled.withComponent = (
|
||||
nextTag: StyledElementType<Props>,
|
||||
nextOptions?: StyledOptions
|
||||
) => {
|
||||
return createStyled(nextTag, {
|
||||
...options,
|
||||
// $FlowFixMe
|
||||
...nextOptions,
|
||||
shouldForwardProp: composeShouldForwardProps(Styled, nextOptions, true)
|
||||
})(...styles)
|
||||
}
|
||||
|
||||
return Styled
|
||||
}
|
||||
}
|
||||
|
||||
export default createStyled
|
||||
2
mc_test/node_modules/@emotion/styled/src/index.d.ts
generated
vendored
Executable file
2
mc_test/node_modules/@emotion/styled/src/index.d.ts
generated
vendored
Executable file
@ -0,0 +1,2 @@
|
||||
export * from '../types'
|
||||
export { default } from '../types'
|
||||
13
mc_test/node_modules/@emotion/styled/src/index.js
generated
vendored
Executable file
13
mc_test/node_modules/@emotion/styled/src/index.js
generated
vendored
Executable file
@ -0,0 +1,13 @@
|
||||
// @flow
|
||||
import styled from './base'
|
||||
import { tags } from './tags'
|
||||
|
||||
// bind it to avoid mutating the original function
|
||||
const newStyled = styled.bind()
|
||||
|
||||
tags.forEach(tagName => {
|
||||
// $FlowFixMe: we can ignore this because its exposed type is defined by the CreateStyled type
|
||||
newStyled[tagName] = newStyled(tagName)
|
||||
})
|
||||
|
||||
export default newStyled
|
||||
139
mc_test/node_modules/@emotion/styled/src/tags.js
generated
vendored
Executable file
139
mc_test/node_modules/@emotion/styled/src/tags.js
generated
vendored
Executable file
@ -0,0 +1,139 @@
|
||||
// @flow
|
||||
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'
|
||||
]
|
||||
83
mc_test/node_modules/@emotion/styled/src/utils.js
generated
vendored
Executable file
83
mc_test/node_modules/@emotion/styled/src/utils.js
generated
vendored
Executable file
@ -0,0 +1,83 @@
|
||||
// @flow
|
||||
import type {
|
||||
ElementType,
|
||||
StatelessFunctionalComponent,
|
||||
AbstractComponent
|
||||
} from 'react'
|
||||
import isPropValid from '@emotion/is-prop-valid'
|
||||
|
||||
export type Interpolations = Array<any>
|
||||
|
||||
export type StyledElementType<Props> =
|
||||
| string
|
||||
| AbstractComponent<{ ...Props, className: string }, mixed>
|
||||
|
||||
export type StyledOptions = {
|
||||
label?: string,
|
||||
shouldForwardProp?: string => boolean,
|
||||
target?: string
|
||||
}
|
||||
|
||||
export type StyledComponent<Props> = StatelessFunctionalComponent<Props> & {
|
||||
defaultProps: any,
|
||||
toString: () => string,
|
||||
withComponent: (
|
||||
nextTag: StyledElementType<Props>,
|
||||
nextOptions?: StyledOptions
|
||||
) => StyledComponent<Props>
|
||||
}
|
||||
|
||||
export type PrivateStyledComponent<Props> = StyledComponent<Props> & {
|
||||
__emotion_real: StyledComponent<Props>,
|
||||
__emotion_base: any,
|
||||
__emotion_styles: any,
|
||||
__emotion_forwardProp: any
|
||||
}
|
||||
|
||||
const testOmitPropsOnStringTag = isPropValid
|
||||
const testOmitPropsOnComponent = (key: string) => key !== 'theme'
|
||||
|
||||
export const getDefaultShouldForwardProp = (tag: 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: PrivateStyledComponent<any>,
|
||||
options: StyledOptions | void,
|
||||
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
|
||||
}
|
||||
|
||||
export type CreateStyledComponent = <Props>(
|
||||
...args: Interpolations
|
||||
) => StyledComponent<Props>
|
||||
|
||||
export type CreateStyled = {
|
||||
<Props>(
|
||||
tag: StyledElementType<Props>,
|
||||
options?: StyledOptions
|
||||
): (...args: Interpolations) => StyledComponent<Props>,
|
||||
[key: string]: CreateStyledComponent,
|
||||
bind: () => CreateStyled
|
||||
}
|
||||
Reference in New Issue
Block a user