paradiego
This commit is contained in:
3
node_modules/@emotion/react/src/_isolated-hnrs.d.ts
generated
vendored
Normal file
3
node_modules/@emotion/react/src/_isolated-hnrs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// this entry point is not publicly available so we don't need to expose any types here
|
||||
// we need to define a definition file for each entrypoint though, otherwise Preconstruct might get confused
|
||||
export {}
|
||||
10
node_modules/@emotion/react/src/_isolated-hnrs.js
generated
vendored
Normal file
10
node_modules/@emotion/react/src/_isolated-hnrs.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// this file isolates this package that is not tree-shakeable
|
||||
// and allows it to be dropped - if it stays unused
|
||||
// it happens thanks to sideEffects: false in our package.json
|
||||
import hoistNonReactStatics from 'hoist-non-react-statics'
|
||||
|
||||
// have to wrap it in a proxy function because Rollup is too damn smart
|
||||
// and if this module doesn't actually contain any logic of its own
|
||||
// then Rollup just use 'hoist-non-react-statics' directly in other chunks
|
||||
export default (targetComponent, sourceComponent) =>
|
||||
hoistNonReactStatics(targetComponent, sourceComponent)
|
||||
169
node_modules/@emotion/react/src/class-names.js
generated
vendored
Normal file
169
node_modules/@emotion/react/src/class-names.js
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
import * as React from 'react'
|
||||
import {
|
||||
getRegisteredStyles,
|
||||
insertStyles,
|
||||
registerStyles
|
||||
} from '@emotion/utils'
|
||||
import { serializeStyles } from '@emotion/serialize'
|
||||
import isDevelopment from '#is-development'
|
||||
import { withEmotionCache } from './context'
|
||||
import { ThemeContext } from './theming'
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks'
|
||||
import isBrowser from '#is-browser'
|
||||
|
||||
/*
|
||||
type ClassNameArg =
|
||||
| string
|
||||
| boolean
|
||||
| { [key: string]: boolean }
|
||||
| Array<ClassNameArg>
|
||||
| null
|
||||
| void
|
||||
*/
|
||||
|
||||
let classnames = (args /*: Array<ClassNameArg> */) /*: string */ => {
|
||||
let len = args.length
|
||||
let i = 0
|
||||
let cls = ''
|
||||
for (; i < len; i++) {
|
||||
let arg = args[i]
|
||||
if (arg == null) continue
|
||||
|
||||
let toAdd
|
||||
switch (typeof arg) {
|
||||
case 'boolean':
|
||||
break
|
||||
case 'object': {
|
||||
if (Array.isArray(arg)) {
|
||||
toAdd = classnames(arg)
|
||||
} else {
|
||||
if (
|
||||
isDevelopment &&
|
||||
arg.styles !== undefined &&
|
||||
arg.name !== undefined
|
||||
) {
|
||||
console.error(
|
||||
'You have passed styles created with `css` from `@emotion/react` package to the `cx`.\n' +
|
||||
'`cx` is meant to compose class names (strings) so you should convert those styles to a class name by passing them to the `css` received from <ClassNames/> component.'
|
||||
)
|
||||
}
|
||||
toAdd = ''
|
||||
for (const k in arg) {
|
||||
if (arg[k] && k) {
|
||||
toAdd && (toAdd += ' ')
|
||||
toAdd += k
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
default: {
|
||||
toAdd = arg
|
||||
}
|
||||
}
|
||||
if (toAdd) {
|
||||
cls && (cls += ' ')
|
||||
cls += toAdd
|
||||
}
|
||||
}
|
||||
return cls
|
||||
}
|
||||
function merge(
|
||||
registered /*: Object */,
|
||||
css /*: (...args: Array<any>) => string */,
|
||||
className /*: string */
|
||||
) {
|
||||
const registeredStyles = []
|
||||
|
||||
const rawClassName = getRegisteredStyles(
|
||||
registered,
|
||||
registeredStyles,
|
||||
className
|
||||
)
|
||||
|
||||
if (registeredStyles.length < 2) {
|
||||
return className
|
||||
}
|
||||
return rawClassName + css(registeredStyles)
|
||||
}
|
||||
|
||||
const Insertion = ({ cache, serializedArr }) => {
|
||||
let rules = useInsertionEffectAlwaysWithSyncFallback(() => {
|
||||
let rules = ''
|
||||
for (let i = 0; i < serializedArr.length; i++) {
|
||||
let res = insertStyles(cache, serializedArr[i], false)
|
||||
if (!isBrowser && res !== undefined) {
|
||||
rules += res
|
||||
}
|
||||
}
|
||||
if (!isBrowser) {
|
||||
return rules
|
||||
}
|
||||
})
|
||||
|
||||
if (!isBrowser && rules.length !== 0) {
|
||||
return (
|
||||
<style
|
||||
{...{
|
||||
[`data-emotion`]: `${cache.key} ${serializedArr
|
||||
.map(serialized => serialized.name)
|
||||
.join(' ')}`,
|
||||
dangerouslySetInnerHTML: { __html: rules },
|
||||
nonce: cache.sheet.nonce
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/*
|
||||
type Props = {
|
||||
children: ({
|
||||
css: (...args: any) => string,
|
||||
cx: (...args: Array<ClassNameArg>) => string,
|
||||
theme: Object
|
||||
}) => React.Node
|
||||
} */
|
||||
|
||||
export const ClassNames /*: React.AbstractComponent<Props>*/ =
|
||||
/* #__PURE__ */ withEmotionCache((props, cache) => {
|
||||
let hasRendered = false
|
||||
let serializedArr = []
|
||||
|
||||
let css = (...args /*: Array<any> */) => {
|
||||
if (hasRendered && isDevelopment) {
|
||||
throw new Error('css can only be used during render')
|
||||
}
|
||||
|
||||
let serialized = serializeStyles(args, cache.registered)
|
||||
serializedArr.push(serialized)
|
||||
// registration has to happen here as the result of this might get consumed by `cx`
|
||||
registerStyles(cache, serialized, false)
|
||||
return `${cache.key}-${serialized.name}`
|
||||
}
|
||||
let cx = (...args /*: Array<ClassNameArg>*/) => {
|
||||
if (hasRendered && isDevelopment) {
|
||||
throw new Error('cx can only be used during render')
|
||||
}
|
||||
return merge(cache.registered, css, classnames(args))
|
||||
}
|
||||
let content = {
|
||||
css,
|
||||
cx,
|
||||
theme: React.useContext(ThemeContext)
|
||||
}
|
||||
let ele = props.children(content)
|
||||
hasRendered = true
|
||||
|
||||
return (
|
||||
<>
|
||||
<Insertion cache={cache} serializedArr={serializedArr} />
|
||||
{ele}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
if (isDevelopment) {
|
||||
ClassNames.displayName = 'EmotionClassNames'
|
||||
}
|
||||
1
node_modules/@emotion/react/src/conditions/false.js
generated
vendored
Normal file
1
node_modules/@emotion/react/src/conditions/false.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default false
|
||||
1
node_modules/@emotion/react/src/conditions/is-browser.js
generated
vendored
Normal file
1
node_modules/@emotion/react/src/conditions/is-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default typeof document !== 'undefined'
|
||||
1
node_modules/@emotion/react/src/conditions/true.js
generated
vendored
Normal file
1
node_modules/@emotion/react/src/conditions/true.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default true
|
||||
69
node_modules/@emotion/react/src/context.js
generated
vendored
Normal file
69
node_modules/@emotion/react/src/context.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/* import { type EmotionCache } from '@emotion/utils' */
|
||||
import * as React from 'react'
|
||||
import { useContext, forwardRef } from 'react'
|
||||
import createCache from '@emotion/cache'
|
||||
import isDevelopment from '#is-development'
|
||||
import isBrowser from '#is-browser'
|
||||
|
||||
let EmotionCacheContext /*: React.Context<EmotionCache | null> */ =
|
||||
/* #__PURE__ */ React.createContext(
|
||||
// we're doing this to avoid preconstruct's dead code elimination in this one case
|
||||
// because this module is primarily intended for the browser and node
|
||||
// but it's also required in react native and similar environments sometimes
|
||||
// and we could have a special build just for that
|
||||
// but this is much easier and the native packages
|
||||
// might use a different theme context in the future anyway
|
||||
typeof HTMLElement !== 'undefined'
|
||||
? /* #__PURE__ */ createCache({ key: 'css' })
|
||||
: null
|
||||
)
|
||||
|
||||
if (isDevelopment) {
|
||||
EmotionCacheContext.displayName = 'EmotionCacheContext'
|
||||
}
|
||||
|
||||
export let CacheProvider = EmotionCacheContext.Provider
|
||||
|
||||
export let __unsafe_useEmotionCache =
|
||||
function useEmotionCache() /*: EmotionCache | null*/ {
|
||||
return useContext(EmotionCacheContext)
|
||||
}
|
||||
|
||||
let withEmotionCache =
|
||||
function withEmotionCache /* <Props, Ref: React.Ref<*>> */(
|
||||
func /*: (props: Props, cache: EmotionCache, ref: Ref) => React.Node */
|
||||
) /*: React.AbstractComponent<Props> */ {
|
||||
return forwardRef((props /*: Props */, ref /*: Ref */) => {
|
||||
// the cache will never be null in the browser
|
||||
let cache = useContext(EmotionCacheContext)
|
||||
|
||||
return func(props, cache, ref)
|
||||
})
|
||||
}
|
||||
|
||||
if (!isBrowser) {
|
||||
withEmotionCache = function withEmotionCache /* <Props> */(
|
||||
func /*: (props: Props, cache: EmotionCache) => React.Node */
|
||||
) /*: React.StatelessFunctionalComponent<Props> */ {
|
||||
return (props /*: Props */) => {
|
||||
let cache = useContext(EmotionCacheContext)
|
||||
if (cache === null) {
|
||||
// yes, we're potentially creating this on every render
|
||||
// it doesn't actually matter though since it's only on the server
|
||||
// so there will only every be a single render
|
||||
// that could change in the future because of suspense and etc. but for now,
|
||||
// this works and i don't want to optimise for a future thing that we aren't sure about
|
||||
cache = createCache({ key: 'css' })
|
||||
return (
|
||||
<EmotionCacheContext.Provider value={cache}>
|
||||
{func(props, cache)}
|
||||
</EmotionCacheContext.Provider>
|
||||
)
|
||||
} else {
|
||||
return func(props, cache)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { withEmotionCache }
|
||||
8
node_modules/@emotion/react/src/css.js
generated
vendored
Normal file
8
node_modules/@emotion/react/src/css.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* import type { Interpolation, SerializedStyles } from '@emotion/utils' */
|
||||
import { serializeStyles } from '@emotion/serialize'
|
||||
|
||||
function css(...args /*: Array<Interpolation> */) /*: SerializedStyles */ {
|
||||
return serializeStyles(args)
|
||||
}
|
||||
|
||||
export default css
|
||||
173
node_modules/@emotion/react/src/emotion-element.js
generated
vendored
Normal file
173
node_modules/@emotion/react/src/emotion-element.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
import * as React from 'react'
|
||||
import { withEmotionCache } from './context'
|
||||
import { ThemeContext } from './theming'
|
||||
import {
|
||||
getRegisteredStyles,
|
||||
insertStyles,
|
||||
registerStyles
|
||||
} from '@emotion/utils'
|
||||
import { hasOwn } from './utils'
|
||||
import { serializeStyles } from '@emotion/serialize'
|
||||
import isDevelopment from '#is-development'
|
||||
import isBrowser from '#is-browser'
|
||||
import { getLabelFromStackTrace } from './get-label-from-stack-trace'
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks'
|
||||
|
||||
let typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__'
|
||||
|
||||
let labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__'
|
||||
|
||||
export const createEmotionProps = (
|
||||
type /*: React.ElementType */,
|
||||
props /*: Object */
|
||||
) => {
|
||||
if (
|
||||
isDevelopment &&
|
||||
typeof props.css === 'string' &&
|
||||
// check if there is a css declaration
|
||||
props.css.indexOf(':') !== -1
|
||||
) {
|
||||
throw new Error(
|
||||
`Strings are not allowed as css prop values, please wrap it in a css template literal from '@emotion/react' like this: css\`${props.css}\``
|
||||
)
|
||||
}
|
||||
|
||||
let newProps /*: any */ = {}
|
||||
|
||||
for (let key in props) {
|
||||
if (hasOwn.call(props, key)) {
|
||||
newProps[key] = props[key]
|
||||
}
|
||||
}
|
||||
|
||||
newProps[typePropName] = type
|
||||
|
||||
// Runtime labeling is an opt-in feature because:
|
||||
// - It causes hydration warnings when using Safari and SSR
|
||||
// - It can degrade performance if there are a huge number of elements
|
||||
//
|
||||
// Even if the flag is set, we still don't compute the label if it has already
|
||||
// been determined by the Babel plugin.
|
||||
if (
|
||||
isDevelopment &&
|
||||
typeof globalThis !== 'undefined' &&
|
||||
!!globalThis.EMOTION_RUNTIME_AUTO_LABEL &&
|
||||
!!props.css &&
|
||||
(typeof props.css !== 'object' ||
|
||||
typeof props.css.name !== 'string' ||
|
||||
props.css.name.indexOf('-') === -1)
|
||||
) {
|
||||
const label = getLabelFromStackTrace(new Error().stack)
|
||||
if (label) newProps[labelPropName] = label
|
||||
}
|
||||
|
||||
return newProps
|
||||
}
|
||||
|
||||
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 Emotion = /* #__PURE__ */ withEmotionCache(
|
||||
/* <any, any> */ (props, cache, ref) => {
|
||||
let cssProp = props.css
|
||||
|
||||
// so that using `css` from `emotion` and passing the result to the css prop works
|
||||
// not passing the registered cache to serializeStyles because it would
|
||||
// make certain babel optimisations not possible
|
||||
if (
|
||||
typeof cssProp === 'string' &&
|
||||
cache.registered[cssProp] !== undefined
|
||||
) {
|
||||
cssProp = cache.registered[cssProp]
|
||||
}
|
||||
|
||||
let WrappedComponent = props[typePropName]
|
||||
let registeredStyles = [cssProp]
|
||||
let className = ''
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = getRegisteredStyles(
|
||||
cache.registered,
|
||||
registeredStyles,
|
||||
props.className
|
||||
)
|
||||
} else if (props.className != null) {
|
||||
className = `${props.className} `
|
||||
}
|
||||
|
||||
let serialized = serializeStyles(
|
||||
registeredStyles,
|
||||
undefined,
|
||||
React.useContext(ThemeContext)
|
||||
)
|
||||
|
||||
if (isDevelopment && serialized.name.indexOf('-') === -1) {
|
||||
let labelFromStack = props[labelPropName]
|
||||
if (labelFromStack) {
|
||||
serialized = serializeStyles([
|
||||
serialized,
|
||||
'label:' + labelFromStack + ';'
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
className += `${cache.key}-${serialized.name}`
|
||||
|
||||
const newProps = {}
|
||||
for (let key in props) {
|
||||
if (
|
||||
hasOwn.call(props, key) &&
|
||||
key !== 'css' &&
|
||||
key !== typePropName &&
|
||||
(!isDevelopment || key !== labelPropName)
|
||||
) {
|
||||
newProps[key] = props[key]
|
||||
}
|
||||
}
|
||||
newProps.className = className
|
||||
if (ref) {
|
||||
newProps.ref = ref
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Insertion
|
||||
cache={cache}
|
||||
serialized={serialized}
|
||||
isStringTag={typeof WrappedComponent === 'string'}
|
||||
/>
|
||||
<WrappedComponent {...newProps} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
if (isDevelopment) {
|
||||
Emotion.displayName = 'EmotionCssPropInternal'
|
||||
}
|
||||
|
||||
export default Emotion
|
||||
52
node_modules/@emotion/react/src/get-label-from-stack-trace.js
generated
vendored
Normal file
52
node_modules/@emotion/react/src/get-label-from-stack-trace.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
const getLastPart = (functionName /* : string */) /* : string */ => {
|
||||
// The match may be something like 'Object.createEmotionProps' or
|
||||
// 'Loader.prototype.render'
|
||||
const parts = functionName.split('.')
|
||||
return parts[parts.length - 1]
|
||||
}
|
||||
|
||||
const getFunctionNameFromStackTraceLine = (line /*: string*/) /*: ?string*/ => {
|
||||
// V8
|
||||
let match = /^\s+at\s+([A-Za-z0-9$.]+)\s/.exec(line)
|
||||
if (match) return getLastPart(match[1])
|
||||
|
||||
// Safari / Firefox
|
||||
match = /^([A-Za-z0-9$.]+)@/.exec(line)
|
||||
if (match) return getLastPart(match[1])
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
const internalReactFunctionNames = /* #__PURE__ */ new Set([
|
||||
'renderWithHooks',
|
||||
'processChild',
|
||||
'finishClassComponent',
|
||||
'renderToString'
|
||||
])
|
||||
|
||||
// These identifiers come from error stacks, so they have to be valid JS
|
||||
// identifiers, thus we only need to replace what is a valid character for JS,
|
||||
// but not for CSS.
|
||||
const sanitizeIdentifier = identifier => identifier.replace(/\$/g, '-')
|
||||
|
||||
export const getLabelFromStackTrace = stackTrace => {
|
||||
if (!stackTrace) return undefined
|
||||
|
||||
const lines = stackTrace.split('\n')
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const functionName = getFunctionNameFromStackTraceLine(lines[i])
|
||||
|
||||
// The first line of V8 stack traces is just "Error"
|
||||
if (!functionName) continue
|
||||
|
||||
// If we reach one of these, we have gone too far and should quit
|
||||
if (internalReactFunctionNames.has(functionName)) break
|
||||
|
||||
// The component name is the first function in the stack that starts with an
|
||||
// uppercase letter
|
||||
if (/^[A-Z]/.test(functionName)) return sanitizeIdentifier(functionName)
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
145
node_modules/@emotion/react/src/global.js
generated
vendored
Normal file
145
node_modules/@emotion/react/src/global.js
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
import * as React from 'react'
|
||||
import isDevelopment from '#is-development'
|
||||
import { withEmotionCache } from './context'
|
||||
import { ThemeContext } from './theming'
|
||||
import { insertStyles } from '@emotion/utils'
|
||||
import isBrowser from '#is-browser'
|
||||
import { useInsertionEffectWithLayoutFallback } from '@emotion/use-insertion-effect-with-fallbacks'
|
||||
|
||||
import { serializeStyles } from '@emotion/serialize'
|
||||
|
||||
/*
|
||||
type Styles = Object | Array<Object>
|
||||
|
||||
type GlobalProps = {
|
||||
+styles: Styles | (Object => Styles)
|
||||
}
|
||||
*/
|
||||
|
||||
let warnedAboutCssPropForGlobal = false
|
||||
|
||||
// maintain place over rerenders.
|
||||
// initial render from browser, insertBefore context.sheet.tags[0] or if a style hasn't been inserted there yet, appendChild
|
||||
// initial client-side render from SSR, use place of hydrating tag
|
||||
|
||||
export let Global /*: React.AbstractComponent<
|
||||
GlobalProps
|
||||
> */ = /* #__PURE__ */ withEmotionCache((props /*: GlobalProps */, cache) => {
|
||||
if (
|
||||
isDevelopment &&
|
||||
!warnedAboutCssPropForGlobal && // check for className as well since the user is
|
||||
// probably using the custom createElement which
|
||||
// means it will be turned into a className prop
|
||||
// I don't really want to add it to the type since it shouldn't be used
|
||||
(props.className || props.css)
|
||||
) {
|
||||
console.error(
|
||||
"It looks like you're using the css prop on Global, did you mean to use the styles prop instead?"
|
||||
)
|
||||
warnedAboutCssPropForGlobal = true
|
||||
}
|
||||
let styles = props.styles
|
||||
|
||||
let serialized = serializeStyles(
|
||||
[styles],
|
||||
undefined,
|
||||
React.useContext(ThemeContext)
|
||||
)
|
||||
|
||||
if (!isBrowser) {
|
||||
let serializedNames = serialized.name
|
||||
let serializedStyles = serialized.styles
|
||||
let next = serialized.next
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name
|
||||
serializedStyles += next.styles
|
||||
next = next.next
|
||||
}
|
||||
|
||||
let shouldCache = cache.compat === true
|
||||
|
||||
let rules = cache.insert(
|
||||
``,
|
||||
{ name: serializedNames, styles: serializedStyles },
|
||||
cache.sheet,
|
||||
shouldCache
|
||||
)
|
||||
|
||||
if (shouldCache) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<style
|
||||
{...{
|
||||
[`data-emotion`]: `${cache.key}-global ${serializedNames}`,
|
||||
dangerouslySetInnerHTML: { __html: rules },
|
||||
nonce: cache.sheet.nonce
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
// yes, i know these hooks are used conditionally
|
||||
// but it is based on a constant that will never change at runtime
|
||||
// it's effectively like having two implementations and switching them out
|
||||
// so it's not actually breaking anything
|
||||
|
||||
let sheetRef = React.useRef()
|
||||
|
||||
useInsertionEffectWithLayoutFallback(() => {
|
||||
const key = `${cache.key}-global`
|
||||
|
||||
// use case of https://github.com/emotion-js/emotion/issues/2675
|
||||
let sheet = new cache.sheet.constructor({
|
||||
key,
|
||||
nonce: cache.sheet.nonce,
|
||||
container: cache.sheet.container,
|
||||
speedy: cache.sheet.isSpeedy
|
||||
})
|
||||
let rehydrating = false
|
||||
let node /*: HTMLStyleElement | null*/ = document.querySelector(
|
||||
`style[data-emotion="${key} ${serialized.name}"]`
|
||||
)
|
||||
if (cache.sheet.tags.length) {
|
||||
sheet.before = cache.sheet.tags[0]
|
||||
}
|
||||
if (node !== null) {
|
||||
rehydrating = true
|
||||
// clear the hash so this node won't be recognizable as rehydratable by other <Global/>s
|
||||
node.setAttribute('data-emotion', key)
|
||||
sheet.hydrate([node])
|
||||
}
|
||||
sheetRef.current = [sheet, rehydrating]
|
||||
return () => {
|
||||
sheet.flush()
|
||||
}
|
||||
}, [cache])
|
||||
|
||||
useInsertionEffectWithLayoutFallback(() => {
|
||||
let sheetRefCurrent = sheetRef.current
|
||||
let [sheet, rehydrating] = sheetRefCurrent
|
||||
if (rehydrating) {
|
||||
sheetRefCurrent[1] = false
|
||||
return
|
||||
}
|
||||
if (serialized.next !== undefined) {
|
||||
// insert keyframes
|
||||
insertStyles(cache, serialized.next, true)
|
||||
}
|
||||
|
||||
if (sheet.tags.length) {
|
||||
// if this doesn't exist then it will be null so the style element will be appended
|
||||
let element = sheet.tags[sheet.tags.length - 1].nextElementSibling
|
||||
sheet.before = element
|
||||
sheet.flush()
|
||||
}
|
||||
cache.insert(``, serialized, sheet, false)
|
||||
}, [cache, serialized.name])
|
||||
|
||||
return null
|
||||
})
|
||||
|
||||
if (isDevelopment) {
|
||||
Global.displayName = 'EmotionGlobal'
|
||||
}
|
||||
1
node_modules/@emotion/react/src/index.d.ts
generated
vendored
Normal file
1
node_modules/@emotion/react/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from '../types/index'
|
||||
42
node_modules/@emotion/react/src/index.js
generated
vendored
Normal file
42
node_modules/@emotion/react/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import isDevelopment from '#is-development'
|
||||
import pkg from '../package.json'
|
||||
// export type { SerializedStyles } from '@emotion/utils'
|
||||
export {
|
||||
withEmotionCache,
|
||||
CacheProvider,
|
||||
__unsafe_useEmotionCache
|
||||
} from './context'
|
||||
export { jsx } from './jsx'
|
||||
export { jsx as createElement } from './jsx'
|
||||
export { Global } from './global'
|
||||
export { keyframes } from './keyframes'
|
||||
export { ClassNames } from './class-names'
|
||||
export { ThemeContext, useTheme, ThemeProvider, withTheme } from './theming'
|
||||
export { default as css } from './css'
|
||||
|
||||
if (isDevelopment) {
|
||||
const isBrowser = typeof document !== 'undefined'
|
||||
// #1727, #2905 for some reason Jest and Vitest evaluate modules twice if some consuming module gets mocked
|
||||
const isTestEnv = typeof jest !== 'undefined' || typeof vi !== 'undefined'
|
||||
|
||||
if (isBrowser && !isTestEnv) {
|
||||
// globalThis has wide browser support - https://caniuse.com/?search=globalThis, Node.js 12 and later
|
||||
const globalContext =
|
||||
// $FlowIgnore
|
||||
typeof globalThis !== 'undefined'
|
||||
? globalThis // eslint-disable-line no-undef
|
||||
: isBrowser
|
||||
? window
|
||||
: global
|
||||
const globalKey = `__EMOTION_REACT_${pkg.version.split('.')[0]}__`
|
||||
if (globalContext[globalKey]) {
|
||||
console.warn(
|
||||
'You are loading @emotion/react when it is already loaded. Running ' +
|
||||
'multiple instances may cause problems. This can happen if multiple ' +
|
||||
'versions are used, or if multiple builds of the same version are ' +
|
||||
'used.'
|
||||
)
|
||||
}
|
||||
globalContext[globalKey] = true
|
||||
}
|
||||
}
|
||||
1
node_modules/@emotion/react/src/jsx-dev-runtime.d.ts
generated
vendored
Normal file
1
node_modules/@emotion/react/src/jsx-dev-runtime.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from '../types/jsx-dev-runtime'
|
||||
27
node_modules/@emotion/react/src/jsx-dev-runtime.js
generated
vendored
Normal file
27
node_modules/@emotion/react/src/jsx-dev-runtime.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as ReactJSXRuntimeDev from 'react/jsx-dev-runtime'
|
||||
import Emotion, { createEmotionProps } from './emotion-element'
|
||||
import { hasOwn } from './utils'
|
||||
|
||||
export const Fragment = ReactJSXRuntimeDev.Fragment
|
||||
|
||||
export function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntimeDev.jsxDEV(
|
||||
type,
|
||||
props,
|
||||
key,
|
||||
isStaticChildren,
|
||||
source,
|
||||
self
|
||||
)
|
||||
}
|
||||
|
||||
return ReactJSXRuntimeDev.jsxDEV(
|
||||
Emotion,
|
||||
createEmotionProps(type, props),
|
||||
key,
|
||||
isStaticChildren,
|
||||
source,
|
||||
self
|
||||
)
|
||||
}
|
||||
1
node_modules/@emotion/react/src/jsx-runtime.d.ts
generated
vendored
Normal file
1
node_modules/@emotion/react/src/jsx-runtime.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from '../types/jsx-runtime'
|
||||
21
node_modules/@emotion/react/src/jsx-runtime.js
generated
vendored
Normal file
21
node_modules/@emotion/react/src/jsx-runtime.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as ReactJSXRuntime from 'react/jsx-runtime'
|
||||
import Emotion, { createEmotionProps } from './emotion-element'
|
||||
import { hasOwn } from './utils'
|
||||
|
||||
export const Fragment = ReactJSXRuntime.Fragment
|
||||
|
||||
export function jsx(type, props, key) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsx(type, props, key)
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsx(Emotion, createEmotionProps(type, props), key)
|
||||
}
|
||||
|
||||
export function jsxs(type, props, key) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsxs(type, props, key)
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsxs(Emotion, createEmotionProps(type, props), key)
|
||||
}
|
||||
25
node_modules/@emotion/react/src/jsx.js
generated
vendored
Normal file
25
node_modules/@emotion/react/src/jsx.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as React from 'react'
|
||||
import Emotion, { createEmotionProps } from './emotion-element'
|
||||
import { hasOwn } from './utils'
|
||||
|
||||
export const jsx /*: typeof React.createElement */ = function (
|
||||
type /*: React.ElementType */,
|
||||
props /*: Object */
|
||||
) {
|
||||
let args = arguments
|
||||
|
||||
if (props == null || !hasOwn.call(props, 'css')) {
|
||||
return React.createElement.apply(undefined, args)
|
||||
}
|
||||
|
||||
let argsLength = args.length
|
||||
let createElementArgArray = new Array(argsLength)
|
||||
createElementArgArray[0] = Emotion
|
||||
createElementArgArray[1] = createEmotionProps(type, props)
|
||||
|
||||
for (let i = 2; i < argsLength; i++) {
|
||||
createElementArgArray[i] = args[i]
|
||||
}
|
||||
|
||||
return React.createElement.apply(null, createElementArgArray)
|
||||
}
|
||||
23
node_modules/@emotion/react/src/keyframes.js
generated
vendored
Normal file
23
node_modules/@emotion/react/src/keyframes.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import css from './css'
|
||||
|
||||
/*
|
||||
type Keyframes = {|
|
||||
name: string,
|
||||
styles: string,
|
||||
anim: 1,
|
||||
toString: () => string
|
||||
|} & string
|
||||
*/
|
||||
|
||||
export const keyframes = (...args) /*: Keyframes */ => {
|
||||
let insertable = css(...args)
|
||||
const name = `animation-${insertable.name}`
|
||||
return {
|
||||
name,
|
||||
styles: `@keyframes ${name}{${insertable.styles}}`,
|
||||
anim: 1,
|
||||
toString() {
|
||||
return `_EMO_${this.name}_${this.styles}_EMO_`
|
||||
}
|
||||
}
|
||||
}
|
||||
83
node_modules/@emotion/react/src/theming.js
generated
vendored
Normal file
83
node_modules/@emotion/react/src/theming.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
import * as React from 'react'
|
||||
import weakMemoize from '@emotion/weak-memoize'
|
||||
import isDevelopment from '#is-development'
|
||||
import hoistNonReactStatics from './_isolated-hnrs'
|
||||
|
||||
export const ThemeContext = /* #__PURE__ */ React.createContext({})
|
||||
if (isDevelopment) {
|
||||
ThemeContext.displayName = 'EmotionThemeContext'
|
||||
}
|
||||
|
||||
export const useTheme = () => React.useContext(ThemeContext)
|
||||
|
||||
const getTheme = (
|
||||
outerTheme /*: Object */,
|
||||
theme /*: Object | (Object => Object) */
|
||||
) => {
|
||||
if (typeof theme === 'function') {
|
||||
const mergedTheme = theme(outerTheme)
|
||||
if (
|
||||
isDevelopment &&
|
||||
(mergedTheme == null ||
|
||||
typeof mergedTheme !== 'object' ||
|
||||
Array.isArray(mergedTheme))
|
||||
) {
|
||||
throw new Error(
|
||||
'[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!'
|
||||
)
|
||||
}
|
||||
return mergedTheme
|
||||
}
|
||||
if (
|
||||
isDevelopment &&
|
||||
(theme == null || typeof theme !== 'object' || Array.isArray(theme))
|
||||
) {
|
||||
throw new Error(
|
||||
'[ThemeProvider] Please make your theme prop a plain object'
|
||||
)
|
||||
}
|
||||
|
||||
return { ...outerTheme, ...theme }
|
||||
}
|
||||
|
||||
let createCacheWithTheme = /* #__PURE__ */ weakMemoize(outerTheme => {
|
||||
return weakMemoize(theme => {
|
||||
return getTheme(outerTheme, theme)
|
||||
})
|
||||
})
|
||||
|
||||
/*
|
||||
type ThemeProviderProps = {
|
||||
theme: Object | (Object => Object),
|
||||
children: React.Node
|
||||
}
|
||||
*/
|
||||
|
||||
export const ThemeProvider = (props /*: ThemeProviderProps */) => {
|
||||
let theme = React.useContext(ThemeContext)
|
||||
|
||||
if (props.theme !== theme) {
|
||||
theme = createCacheWithTheme(theme)(props.theme)
|
||||
}
|
||||
return (
|
||||
<ThemeContext.Provider value={theme}>
|
||||
{props.children}
|
||||
</ThemeContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function withTheme /* <Config: {}> */(
|
||||
Component /*: React.AbstractComponent<Config> */
|
||||
) /*: React.AbstractComponent<$Diff<Config, { theme: Object }>> */ {
|
||||
const componentName = Component.displayName || Component.name || 'Component'
|
||||
let render = (props, ref) => {
|
||||
let theme = React.useContext(ThemeContext)
|
||||
|
||||
return <Component theme={theme} ref={ref} {...props} />
|
||||
}
|
||||
let WithTheme = React.forwardRef(render)
|
||||
|
||||
WithTheme.displayName = `WithTheme(${componentName})`
|
||||
|
||||
return hoistNonReactStatics(WithTheme, Component)
|
||||
}
|
||||
1
node_modules/@emotion/react/src/utils.js
generated
vendored
Normal file
1
node_modules/@emotion/react/src/utils.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const hasOwn = {}.hasOwnProperty
|
||||
Reference in New Issue
Block a user