pre-installations and preparations
This commit is contained in:
1 parent
3e5a0329cb
commit
201d621ac3
6977 files changed
+742826
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Emotion team and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
# @emotion/react
|
||||
|
||||
> Simple styling in React.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
yarn add @emotion/react
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```jsx
|
||||
/** @jsx jsx */
|
||||
import { jsx, css, Global, ClassNames } from '@emotion/react'
|
||||
|
||||
render(
|
||||
<div css={{ color: 'hotpink' }}>
|
||||
<div
|
||||
css={css`
|
||||
color: green;
|
||||
`}
|
||||
/>
|
||||
<Global
|
||||
styles={{
|
||||
body: {
|
||||
margin: 0,
|
||||
padding: 0
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ClassNames>
|
||||
{({ css, cx }) => (
|
||||
<div
|
||||
className={cx(
|
||||
'some-class',
|
||||
css`
|
||||
color: yellow;
|
||||
`
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</ClassNames>
|
||||
</div>
|
||||
)
|
||||
```
|
||||
|
||||
More documentation is available at [https://emotion.sh](https://emotion.sh).
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import hoistNonReactStatics$1 from 'hoist-non-react-statics';
|
||||
|
||||
// this file isolates this package that is not tree-shakeable
|
||||
// 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
|
||||
|
||||
var hoistNonReactStatics = (function (targetComponent, sourceComponent) {
|
||||
return hoistNonReactStatics$1(targetComponent, sourceComponent);
|
||||
});
|
||||
|
||||
export { hoistNonReactStatics as default };
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export * from "../../dist/declarations/src/_isolated-hnrs.js";
|
||||
export { _default as default } from "./emotion-react-_isolated-hnrs.cjs.default.js";
|
||||
//# sourceMappingURL=emotion-react-_isolated-hnrs.cjs.d.mts.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-_isolated-hnrs.cjs.d.mts","sourceRoot":"","sources":["../../dist/declarations/src/_isolated-hnrs.d.ts"],"names":[],"mappings":"AAAA"}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export * from "../../dist/declarations/src/_isolated-hnrs";
|
||||
export { default } from "../../dist/declarations/src/_isolated-hnrs";
|
||||
//# sourceMappingURL=emotion-react-_isolated-hnrs.cjs.d.ts.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-_isolated-hnrs.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/_isolated-hnrs.d.ts"],"names":[],"mappings":"AAAA"}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { default as _default } from "../../dist/declarations/src/_isolated-hnrs.js"
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
exports._default = require("./emotion-react-_isolated-hnrs.cjs.js").default;
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var hoistNonReactStatics$1 = require('hoist-non-react-statics');
|
||||
|
||||
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
||||
|
||||
var hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReactStatics$1);
|
||||
|
||||
// this file isolates this package that is not tree-shakeable
|
||||
// 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
|
||||
|
||||
var hoistNonReactStatics = (function (targetComponent, sourceComponent) {
|
||||
return hoistNonReactStatics__default["default"](targetComponent, sourceComponent);
|
||||
});
|
||||
|
||||
exports["default"] = hoistNonReactStatics;
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
module.exports = require("./emotion-react-_isolated-hnrs.cjs.prod.js");
|
||||
} else {
|
||||
module.exports = require("./emotion-react-_isolated-hnrs.cjs.dev.js");
|
||||
}
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
|
||||
} from "./emotion-react-_isolated-hnrs.cjs.js";
|
||||
export { _default as default } from "./emotion-react-_isolated-hnrs.cjs.default.js";
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var hoistNonReactStatics$1 = require('hoist-non-react-statics');
|
||||
|
||||
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
||||
|
||||
var hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReactStatics$1);
|
||||
|
||||
// this file isolates this package that is not tree-shakeable
|
||||
// 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
|
||||
|
||||
var hoistNonReactStatics = (function (targetComponent, sourceComponent) {
|
||||
return hoistNonReactStatics__default["default"](targetComponent, sourceComponent);
|
||||
});
|
||||
|
||||
exports["default"] = hoistNonReactStatics;
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import hoistNonReactStatics$1 from 'hoist-non-react-statics';
|
||||
|
||||
// this file isolates this package that is not tree-shakeable
|
||||
// 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
|
||||
|
||||
var hoistNonReactStatics = (function (targetComponent, sourceComponent) {
|
||||
return hoistNonReactStatics$1(targetComponent, sourceComponent);
|
||||
});
|
||||
|
||||
export { hoistNonReactStatics as default };
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).emotionHoistNonReactStatics=t()}(this,(function(){"use strict";function e(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&r.path)}},r.exports),r.exports}var t=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&Symbol.for,o=r?Symbol.for("react.element"):60103,n=r?Symbol.for("react.portal"):60106,f=r?Symbol.for("react.fragment"):60107,c=r?Symbol.for("react.strict_mode"):60108,i=r?Symbol.for("react.profiler"):60114,a=r?Symbol.for("react.provider"):60109,s=r?Symbol.for("react.context"):60110,u=r?Symbol.for("react.async_mode"):60111,p=r?Symbol.for("react.concurrent_mode"):60111,y=r?Symbol.for("react.forward_ref"):60112,l=r?Symbol.for("react.suspense"):60113,m=r?Symbol.for("react.suspense_list"):60120,d=r?Symbol.for("react.memo"):60115,b=r?Symbol.for("react.lazy"):60116,$=r?Symbol.for("react.fundamental"):60117,S=r?Symbol.for("react.responder"):60118,g=r?Symbol.for("react.scope"):60119;function v(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case o:switch(e=e.type){case u:case p:case f:case i:case c:case l:return e;default:switch(e=e&&e.$$typeof){case s:case y:case b:case d:case a:return e;default:return t}}case n:return t}}}function P(e){return v(e)===p}t.typeOf=v,t.AsyncMode=u,t.ConcurrentMode=p,t.ContextConsumer=s,t.ContextProvider=a,t.Element=o,t.ForwardRef=y,t.Fragment=f,t.Lazy=b,t.Memo=d,t.Portal=n,t.Profiler=i,t.StrictMode=c,t.Suspense=l,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===f||e===p||e===i||e===c||e===l||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===b||e.$$typeof===d||e.$$typeof===a||e.$$typeof===s||e.$$typeof===y||e.$$typeof===$||e.$$typeof===S||e.$$typeof===g)},t.isAsyncMode=function(e){return P(e)||v(e)===u},t.isConcurrentMode=P,t.isContextConsumer=function(e){return v(e)===s},t.isContextProvider=function(e){return v(e)===a},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return v(e)===y},t.isFragment=function(e){return v(e)===f},t.isLazy=function(e){return v(e)===b},t.isMemo=function(e){return v(e)===d},t.isPortal=function(e){return v(e)===n},t.isProfiler=function(e){return v(e)===i},t.isStrictMode=function(e){return v(e)===c},t.isSuspense=function(e){return v(e)===l}}));e((function(e,t){}));var r=e((function(e){e.exports=t})),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},f={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},c={};function i(e){return r.isMemo(e)?f:c[e.$$typeof]||o}c[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0};var a=Object.defineProperty,s=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,y=Object.getPrototypeOf,l=Object.prototype;var m=function e(t,r,o){if("string"!=typeof r){if(l){var f=y(r);f&&f!==l&&e(t,f,o)}var c=s(r);u&&(c=c.concat(u(r)));for(var m=i(t),d=i(r),b=0;b<c.length;++b){var $=c[b];if(!(n[$]||o&&o[$]||d&&d[$]||m&&m[$])){var S=p(r,$);try{a(t,$,S)}catch(e){}}}}return t};return function(e,t){return m(e,t)}}));
|
||||
//# sourceMappingURL=emotion-react-_isolated-hnrs.umd.min.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-_isolated-hnrs.umd.min.js","sources":["../../../../node_modules/react-is/cjs/react-is.production.min.js","../../../../node_modules/react-is/index.js","../../../../node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js","../../src/_isolated-hnrs.js"],"sourcesContent":["/** @license React v16.12.0\n * react-is.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';Object.defineProperty(exports,\"__esModule\",{value:!0});\nvar b=\"function\"===typeof Symbol&&Symbol.for,c=b?Symbol.for(\"react.element\"):60103,d=b?Symbol.for(\"react.portal\"):60106,e=b?Symbol.for(\"react.fragment\"):60107,f=b?Symbol.for(\"react.strict_mode\"):60108,g=b?Symbol.for(\"react.profiler\"):60114,h=b?Symbol.for(\"react.provider\"):60109,k=b?Symbol.for(\"react.context\"):60110,l=b?Symbol.for(\"react.async_mode\"):60111,m=b?Symbol.for(\"react.concurrent_mode\"):60111,n=b?Symbol.for(\"react.forward_ref\"):60112,p=b?Symbol.for(\"react.suspense\"):60113,q=b?Symbol.for(\"react.suspense_list\"):\n60120,r=b?Symbol.for(\"react.memo\"):60115,t=b?Symbol.for(\"react.lazy\"):60116,v=b?Symbol.for(\"react.fundamental\"):60117,w=b?Symbol.for(\"react.responder\"):60118,x=b?Symbol.for(\"react.scope\"):60119;function y(a){if(\"object\"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function z(a){return y(a)===m}\nexports.typeOf=y;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;\nexports.isValidElementType=function(a){return\"string\"===typeof a||\"function\"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||\"object\"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w||a.$$typeof===x)};exports.isAsyncMode=function(a){return z(a)||y(a)===l};exports.isConcurrentMode=z;exports.isContextConsumer=function(a){return y(a)===k};exports.isContextProvider=function(a){return y(a)===h};\nexports.isElement=function(a){return\"object\"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return y(a)===n};exports.isFragment=function(a){return y(a)===e};exports.isLazy=function(a){return y(a)===t};exports.isMemo=function(a){return y(a)===r};exports.isPortal=function(a){return y(a)===d};exports.isProfiler=function(a){return y(a)===g};exports.isStrictMode=function(a){return y(a)===f};exports.isSuspense=function(a){return y(a)===p};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-is.production.min.js');\n} else {\n module.exports = require('./cjs/react-is.development.js');\n}\n","'use strict';\n\nvar reactIs = require('react-is');\n\n/**\n * Copyright 2015, Yahoo! Inc.\n * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.\n */\nvar REACT_STATICS = {\n childContextTypes: true,\n contextType: true,\n contextTypes: true,\n defaultProps: true,\n displayName: true,\n getDefaultProps: true,\n getDerivedStateFromError: true,\n getDerivedStateFromProps: true,\n mixins: true,\n propTypes: true,\n type: true\n};\nvar KNOWN_STATICS = {\n name: true,\n length: true,\n prototype: true,\n caller: true,\n callee: true,\n arguments: true,\n arity: true\n};\nvar FORWARD_REF_STATICS = {\n '$$typeof': true,\n render: true,\n defaultProps: true,\n displayName: true,\n propTypes: true\n};\nvar MEMO_STATICS = {\n '$$typeof': true,\n compare: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n type: true\n};\nvar TYPE_STATICS = {};\nTYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;\n\nfunction getStatics(component) {\n if (reactIs.isMemo(component)) {\n return MEMO_STATICS;\n }\n\n return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;\n}\n\nvar defineProperty = Object.defineProperty;\nvar getOwnPropertyNames = Object.getOwnPropertyNames;\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\nvar getPrototypeOf = Object.getPrototypeOf;\nvar objectPrototype = Object.prototype;\nfunction hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {\n if (typeof sourceComponent !== 'string') {\n // don't hoist over string (html) components\n if (objectPrototype) {\n var inheritedComponent = getPrototypeOf(sourceComponent);\n\n if (inheritedComponent && inheritedComponent !== objectPrototype) {\n hoistNonReactStaticLine truncated
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import hoistNonReactStatics$1 from 'hoist-non-react-statics';
|
||||
|
||||
// this file isolates this package that is not tree-shakeable
|
||||
// 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
|
||||
|
||||
var hoistNonReactStatics = (function (targetComponent, sourceComponent) {
|
||||
return hoistNonReactStatics$1(targetComponent, sourceComponent);
|
||||
});
|
||||
|
||||
export { hoistNonReactStatics as default };
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"main": "dist/emotion-react-_isolated-hnrs.cjs.js",
|
||||
"module": "dist/emotion-react-_isolated-hnrs.esm.js",
|
||||
"umd:main": "dist/emotion-react-_isolated-hnrs.umd.min.js",
|
||||
"browser": {
|
||||
"./dist/emotion-react-_isolated-hnrs.esm.js": "./dist/emotion-react-_isolated-hnrs.browser.esm.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"preconstruct": {
|
||||
"umdName": "emotionHoistNonReactStatics"
|
||||
}
|
||||
}
|
||||
+3
@@ -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 {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '../types/index'
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '../types/jsx-dev-runtime'
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '../types/jsx-runtime'
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import * as React from 'react'
|
||||
|
||||
/**
|
||||
* @desc Utility type for getting props type of React component.
|
||||
* It takes `defaultProps` into an account - making props with defaults optional.
|
||||
*/
|
||||
export type PropsOf<
|
||||
C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>
|
||||
> = JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>
|
||||
|
||||
// We need to use this version of Omit as it's distributive (Will preserve unions)
|
||||
export type DistributiveOmit<T, U> = T extends any
|
||||
? Pick<T, Exclude<keyof T, U>>
|
||||
: never
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
|
||||
// TypeScript Version: 3.4
|
||||
|
||||
import { EmotionCache } from '@emotion/cache'
|
||||
import {
|
||||
ArrayInterpolation,
|
||||
ComponentSelector,
|
||||
CSSInterpolation,
|
||||
CSSObject,
|
||||
FunctionInterpolation,
|
||||
Interpolation,
|
||||
Keyframes,
|
||||
SerializedStyles
|
||||
} from '@emotion/serialize'
|
||||
import {
|
||||
ClassAttributes,
|
||||
Context,
|
||||
Provider,
|
||||
FC,
|
||||
ReactElement,
|
||||
ReactNode,
|
||||
Ref,
|
||||
createElement
|
||||
} from 'react'
|
||||
import { EmotionJSX } from './jsx-namespace'
|
||||
|
||||
export {
|
||||
ArrayInterpolation,
|
||||
ComponentSelector,
|
||||
CSSObject,
|
||||
EmotionCache,
|
||||
FunctionInterpolation,
|
||||
Interpolation,
|
||||
Keyframes,
|
||||
SerializedStyles
|
||||
}
|
||||
|
||||
export * from './theming'
|
||||
export * from './helper'
|
||||
|
||||
// tslint:disable-next-line: no-empty-interface
|
||||
export interface Theme {}
|
||||
|
||||
export const ThemeContext: Context<object>
|
||||
export const CacheProvider: Provider<EmotionCache>
|
||||
export function withEmotionCache<Props, RefType = any>(
|
||||
func: (props: Props, context: EmotionCache, ref: Ref<RefType>) => ReactNode
|
||||
): FC<Props & ClassAttributes<RefType>>
|
||||
|
||||
export function css(
|
||||
template: TemplateStringsArray,
|
||||
...args: Array<CSSInterpolation>
|
||||
): SerializedStyles
|
||||
export function css(...args: Array<CSSInterpolation>): SerializedStyles
|
||||
|
||||
export interface GlobalProps {
|
||||
styles: Interpolation<Theme>
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc
|
||||
* JSX generic are supported only after TS@2.9
|
||||
*/
|
||||
export function Global(props: GlobalProps): ReactElement
|
||||
|
||||
export function keyframes(
|
||||
template: TemplateStringsArray,
|
||||
...args: Array<CSSInterpolation>
|
||||
): Keyframes
|
||||
export function keyframes(...args: Array<CSSInterpolation>): Keyframes
|
||||
|
||||
export interface ArrayClassNamesArg extends Array<ClassNamesArg> {}
|
||||
export type ClassNamesArg =
|
||||
| undefined
|
||||
| null
|
||||
| string
|
||||
| boolean
|
||||
| { [className: string]: boolean | null | undefined }
|
||||
| ArrayClassNamesArg
|
||||
|
||||
export interface ClassNamesContent {
|
||||
css(template: TemplateStringsArray, ...args: Array<CSSInterpolation>): string
|
||||
css(...args: Array<CSSInterpolation>): string
|
||||
cx(...args: Array<ClassNamesArg>): string
|
||||
theme: Theme
|
||||
}
|
||||
export interface ClassNamesProps {
|
||||
children(content: ClassNamesContent): ReactNode
|
||||
}
|
||||
/**
|
||||
* @desc
|
||||
* JSX generic are supported only after TS@2.9
|
||||
*/
|
||||
export function ClassNames(props: ClassNamesProps): ReactElement
|
||||
|
||||
export const jsx: typeof createElement
|
||||
export namespace jsx {
|
||||
namespace JSX {
|
||||
type ElementType = EmotionJSX.ElementType
|
||||
interface Element extends EmotionJSX.Element {}
|
||||
interface ElementClass extends EmotionJSX.ElementClass {}
|
||||
interface ElementAttributesProperty
|
||||
extends EmotionJSX.ElementAttributesProperty {}
|
||||
interface ElementChildrenAttribute
|
||||
extends EmotionJSX.ElementChildrenAttribute {}
|
||||
type LibraryManagedAttributes<C, P> = EmotionJSX.LibraryManagedAttributes<
|
||||
C,
|
||||
P
|
||||
>
|
||||
interface IntrinsicAttributes extends EmotionJSX.IntrinsicAttributes {}
|
||||
interface IntrinsicClassAttributes<T>
|
||||
extends EmotionJSX.IntrinsicClassAttributes<T> {}
|
||||
type IntrinsicElements = EmotionJSX.IntrinsicElements
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { EmotionJSX as JSX } from './jsx-namespace'
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import 'react'
|
||||
import { Interpolation } from '@emotion/serialize'
|
||||
import { Theme } from '@emotion/react'
|
||||
|
||||
type WithConditionalCSSProp<P> = 'className' extends keyof P
|
||||
? string extends P['className' & keyof P]
|
||||
? { css?: Interpolation<Theme> }
|
||||
: {}
|
||||
: {}
|
||||
|
||||
// unpack all here to avoid infinite self-referencing when defining our own JSX namespace
|
||||
type ReactJSXElement = JSX.Element
|
||||
type ReactJSXElementClass = JSX.ElementClass
|
||||
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
|
||||
type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
|
||||
type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
|
||||
type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
|
||||
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
|
||||
type ReactJSXIntrinsicElements = JSX.IntrinsicElements
|
||||
|
||||
// based on the code from @types/react@18.2.8
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13
|
||||
type ReactJSXElementType = string | React.JSXElementConstructor<any>
|
||||
|
||||
export namespace EmotionJSX {
|
||||
type ElementType = ReactJSXElementType
|
||||
interface Element extends ReactJSXElement {}
|
||||
interface ElementClass extends ReactJSXElementClass {}
|
||||
interface ElementAttributesProperty
|
||||
extends ReactJSXElementAttributesProperty {}
|
||||
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}
|
||||
|
||||
type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
|
||||
ReactJSXLibraryManagedAttributes<C, P>
|
||||
|
||||
interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
|
||||
interface IntrinsicClassAttributes<T>
|
||||
extends ReactJSXIntrinsicClassAttributes<T> {}
|
||||
|
||||
type IntrinsicElements = {
|
||||
[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
|
||||
css?: Interpolation<Theme>
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { EmotionJSX as JSX } from './jsx-namespace'
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import * as React from 'react'
|
||||
import { Theme } from '@emotion/react'
|
||||
import { DistributiveOmit, PropsOf } from './helper'
|
||||
|
||||
export interface ThemeProviderProps {
|
||||
theme: Partial<Theme> | ((outerTheme: Theme) => Theme)
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
export interface ThemeProvider {
|
||||
(props: ThemeProviderProps): React.ReactElement
|
||||
}
|
||||
|
||||
export type withTheme = <
|
||||
C extends React.ComponentType<React.ComponentProps<C>>
|
||||
>(
|
||||
component: C
|
||||
) => React.FC<DistributiveOmit<PropsOf<C>, 'theme'> & { theme?: Theme }>
|
||||
|
||||
export function useTheme(): Theme
|
||||
|
||||
export const ThemeProvider: ThemeProvider
|
||||
|
||||
export const withTheme: withTheme
|
||||
|
||||
export type WithTheme<P, T> = P extends { theme: infer Theme }
|
||||
? P & { theme: Exclude<Theme, undefined> }
|
||||
: P & { theme: T }
|
||||
+278
@@ -0,0 +1,278 @@
|
||||
import * as React from 'react';
|
||||
import { useContext, forwardRef } from 'react';
|
||||
import createCache from '@emotion/cache';
|
||||
import _extends from '@babel/runtime/helpers/esm/extends';
|
||||
import weakMemoize from '@emotion/weak-memoize';
|
||||
import hoistNonReactStatics from '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js';
|
||||
import { getRegisteredStyles, registerStyles, insertStyles } from '@emotion/utils';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var isBrowser = "undefined" !== 'undefined';
|
||||
var hasOwn = {}.hasOwnProperty;
|
||||
|
||||
var EmotionCacheContext = /* #__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 (process.env.NODE_ENV !== 'production') {
|
||||
EmotionCacheContext.displayName = 'EmotionCacheContext';
|
||||
}
|
||||
|
||||
var CacheProvider = EmotionCacheContext.Provider;
|
||||
var __unsafe_useEmotionCache = function useEmotionCache() {
|
||||
return useContext(EmotionCacheContext);
|
||||
};
|
||||
|
||||
var withEmotionCache = function withEmotionCache(func) {
|
||||
// $FlowFixMe
|
||||
return /*#__PURE__*/forwardRef(function (props, ref) {
|
||||
// the cache will never be null in the browser
|
||||
var cache = useContext(EmotionCacheContext);
|
||||
return func(props, cache, ref);
|
||||
});
|
||||
};
|
||||
|
||||
if (!isBrowser) {
|
||||
withEmotionCache = function withEmotionCache(func) {
|
||||
return function (props) {
|
||||
var 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 /*#__PURE__*/React.createElement(EmotionCacheContext.Provider, {
|
||||
value: cache
|
||||
}, func(props, cache));
|
||||
} else {
|
||||
return func(props, cache);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var ThemeContext = /* #__PURE__ */React.createContext({});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ThemeContext.displayName = 'EmotionThemeContext';
|
||||
}
|
||||
|
||||
var useTheme = function useTheme() {
|
||||
return React.useContext(ThemeContext);
|
||||
};
|
||||
|
||||
var getTheme = function getTheme(outerTheme, theme) {
|
||||
if (typeof theme === 'function') {
|
||||
var mergedTheme = theme(outerTheme);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && (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 (process.env.NODE_ENV !== 'production' && (theme == null || typeof theme !== 'object' || Array.isArray(theme))) {
|
||||
throw new Error('[ThemeProvider] Please make your theme prop a plain object');
|
||||
}
|
||||
|
||||
return _extends({}, outerTheme, theme);
|
||||
};
|
||||
|
||||
var createCacheWithTheme = /* #__PURE__ */weakMemoize(function (outerTheme) {
|
||||
return weakMemoize(function (theme) {
|
||||
return getTheme(outerTheme, theme);
|
||||
});
|
||||
});
|
||||
var ThemeProvider = function ThemeProvider(props) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
|
||||
if (props.theme !== theme) {
|
||||
theme = createCacheWithTheme(theme)(props.theme);
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
||||
value: theme
|
||||
}, props.children);
|
||||
};
|
||||
function withTheme(Component) {
|
||||
var componentName = Component.displayName || Component.name || 'Component';
|
||||
|
||||
var render = function render(props, ref) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
return /*#__PURE__*/React.createElement(Component, _extends({
|
||||
theme: theme,
|
||||
ref: ref
|
||||
}, props));
|
||||
}; // $FlowFixMe
|
||||
|
||||
|
||||
var WithTheme = /*#__PURE__*/React.forwardRef(render);
|
||||
WithTheme.displayName = "WithTheme(" + componentName + ")";
|
||||
return hoistNonReactStatics(WithTheme, Component);
|
||||
}
|
||||
|
||||
var getLastPart = function getLastPart(functionName) {
|
||||
// The match may be something like 'Object.createEmotionProps' or
|
||||
// 'Loader.prototype.render'
|
||||
var parts = functionName.split('.');
|
||||
return parts[parts.length - 1];
|
||||
};
|
||||
|
||||
var getFunctionNameFromStackTraceLine = function getFunctionNameFromStackTraceLine(line) {
|
||||
// V8
|
||||
var 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;
|
||||
};
|
||||
|
||||
var 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.
|
||||
|
||||
var sanitizeIdentifier = function sanitizeIdentifier(identifier) {
|
||||
return identifier.replace(/\$/g, '-');
|
||||
};
|
||||
|
||||
var getLabelFromStackTrace = function getLabelFromStackTrace(stackTrace) {
|
||||
if (!stackTrace) return undefined;
|
||||
var lines = stackTrace.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var 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;
|
||||
};
|
||||
|
||||
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
||||
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
|
||||
var createEmotionProps = function createEmotionProps(type, props) {
|
||||
if (process.env.NODE_ENV !== 'production' && 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 + "`");
|
||||
}
|
||||
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps[typePropName] = type; // For performance, only call getLabelFromStackTrace in development and when
|
||||
// the label hasn't already been computed
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !!props.css && (typeof props.css !== 'object' || typeof props.css.name !== 'string' || props.css.name.indexOf('-') === -1)) {
|
||||
var label = getLabelFromStackTrace(new Error().stack);
|
||||
if (label) newProps[labelPropName] = label;
|
||||
}
|
||||
|
||||
return newProps;
|
||||
};
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serialized = _ref.serialized,
|
||||
isStringTag = _ref.isStringTag;
|
||||
registerStyles(cache, serialized, isStringTag);
|
||||
var rules = useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
return insertStyles(cache, serialized, isStringTag);
|
||||
});
|
||||
|
||||
if (rules !== undefined) {
|
||||
var _ref2;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedNames, _ref2.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
||||
var 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];
|
||||
}
|
||||
|
||||
var WrappedComponent = props[typePropName];
|
||||
var registeredStyles = [cssProp];
|
||||
var className = '';
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = getRegisteredStyles(cache.registered, registeredStyles, props.className);
|
||||
} else if (props.className != null) {
|
||||
className = props.className + " ";
|
||||
}
|
||||
|
||||
var serialized = serializeStyles(registeredStyles, undefined, React.useContext(ThemeContext));
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
|
||||
var labelFromStack = props[labelPropName];
|
||||
|
||||
if (labelFromStack) {
|
||||
serialized = serializeStyles([serialized, 'label:' + labelFromStack + ';']);
|
||||
}
|
||||
}
|
||||
|
||||
className += cache.key + "-" + serialized.name;
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key) && key !== 'css' && key !== typePropName && (process.env.NODE_ENV === 'production' || key !== labelPropName)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps.ref = ref;
|
||||
newProps.className = className;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serialized: serialized,
|
||||
isStringTag: typeof WrappedComponent === 'string'
|
||||
}), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Emotion.displayName = 'EmotionCssPropInternal';
|
||||
}
|
||||
|
||||
var Emotion$1 = Emotion;
|
||||
|
||||
export { CacheProvider as C, Emotion$1 as E, ThemeContext as T, __unsafe_useEmotionCache as _, ThemeProvider as a, withTheme as b, createEmotionProps as c, hasOwn as h, isBrowser as i, useTheme as u, withEmotionCache as w };
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
import * as React from 'react';
|
||||
import { useContext, forwardRef } from 'react';
|
||||
import createCache from '@emotion/cache';
|
||||
import _extends from '@babel/runtime/helpers/esm/extends';
|
||||
import weakMemoize from '@emotion/weak-memoize';
|
||||
import hoistNonReactStatics from '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js';
|
||||
import { getRegisteredStyles, registerStyles, insertStyles } from '@emotion/utils';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var isBrowser = "object" !== 'undefined';
|
||||
var hasOwn = {}.hasOwnProperty;
|
||||
|
||||
var EmotionCacheContext = /* #__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 (process.env.NODE_ENV !== 'production') {
|
||||
EmotionCacheContext.displayName = 'EmotionCacheContext';
|
||||
}
|
||||
|
||||
var CacheProvider = EmotionCacheContext.Provider;
|
||||
var __unsafe_useEmotionCache = function useEmotionCache() {
|
||||
return useContext(EmotionCacheContext);
|
||||
};
|
||||
|
||||
var withEmotionCache = function withEmotionCache(func) {
|
||||
// $FlowFixMe
|
||||
return /*#__PURE__*/forwardRef(function (props, ref) {
|
||||
// the cache will never be null in the browser
|
||||
var cache = useContext(EmotionCacheContext);
|
||||
return func(props, cache, ref);
|
||||
});
|
||||
};
|
||||
|
||||
if (!isBrowser) {
|
||||
withEmotionCache = function withEmotionCache(func) {
|
||||
return function (props) {
|
||||
var 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 /*#__PURE__*/React.createElement(EmotionCacheContext.Provider, {
|
||||
value: cache
|
||||
}, func(props, cache));
|
||||
} else {
|
||||
return func(props, cache);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var ThemeContext = /* #__PURE__ */React.createContext({});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ThemeContext.displayName = 'EmotionThemeContext';
|
||||
}
|
||||
|
||||
var useTheme = function useTheme() {
|
||||
return React.useContext(ThemeContext);
|
||||
};
|
||||
|
||||
var getTheme = function getTheme(outerTheme, theme) {
|
||||
if (typeof theme === 'function') {
|
||||
var mergedTheme = theme(outerTheme);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && (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 (process.env.NODE_ENV !== 'production' && (theme == null || typeof theme !== 'object' || Array.isArray(theme))) {
|
||||
throw new Error('[ThemeProvider] Please make your theme prop a plain object');
|
||||
}
|
||||
|
||||
return _extends({}, outerTheme, theme);
|
||||
};
|
||||
|
||||
var createCacheWithTheme = /* #__PURE__ */weakMemoize(function (outerTheme) {
|
||||
return weakMemoize(function (theme) {
|
||||
return getTheme(outerTheme, theme);
|
||||
});
|
||||
});
|
||||
var ThemeProvider = function ThemeProvider(props) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
|
||||
if (props.theme !== theme) {
|
||||
theme = createCacheWithTheme(theme)(props.theme);
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
||||
value: theme
|
||||
}, props.children);
|
||||
};
|
||||
function withTheme(Component) {
|
||||
var componentName = Component.displayName || Component.name || 'Component';
|
||||
|
||||
var render = function render(props, ref) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
return /*#__PURE__*/React.createElement(Component, _extends({
|
||||
theme: theme,
|
||||
ref: ref
|
||||
}, props));
|
||||
}; // $FlowFixMe
|
||||
|
||||
|
||||
var WithTheme = /*#__PURE__*/React.forwardRef(render);
|
||||
WithTheme.displayName = "WithTheme(" + componentName + ")";
|
||||
return hoistNonReactStatics(WithTheme, Component);
|
||||
}
|
||||
|
||||
var getLastPart = function getLastPart(functionName) {
|
||||
// The match may be something like 'Object.createEmotionProps' or
|
||||
// 'Loader.prototype.render'
|
||||
var parts = functionName.split('.');
|
||||
return parts[parts.length - 1];
|
||||
};
|
||||
|
||||
var getFunctionNameFromStackTraceLine = function getFunctionNameFromStackTraceLine(line) {
|
||||
// V8
|
||||
var 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;
|
||||
};
|
||||
|
||||
var 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.
|
||||
|
||||
var sanitizeIdentifier = function sanitizeIdentifier(identifier) {
|
||||
return identifier.replace(/\$/g, '-');
|
||||
};
|
||||
|
||||
var getLabelFromStackTrace = function getLabelFromStackTrace(stackTrace) {
|
||||
if (!stackTrace) return undefined;
|
||||
var lines = stackTrace.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var 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;
|
||||
};
|
||||
|
||||
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
||||
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
|
||||
var createEmotionProps = function createEmotionProps(type, props) {
|
||||
if (process.env.NODE_ENV !== 'production' && 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 + "`");
|
||||
}
|
||||
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps[typePropName] = type; // For performance, only call getLabelFromStackTrace in development and when
|
||||
// the label hasn't already been computed
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !!props.css && (typeof props.css !== 'object' || typeof props.css.name !== 'string' || props.css.name.indexOf('-') === -1)) {
|
||||
var label = getLabelFromStackTrace(new Error().stack);
|
||||
if (label) newProps[labelPropName] = label;
|
||||
}
|
||||
|
||||
return newProps;
|
||||
};
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serialized = _ref.serialized,
|
||||
isStringTag = _ref.isStringTag;
|
||||
registerStyles(cache, serialized, isStringTag);
|
||||
useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
return insertStyles(cache, serialized, isStringTag);
|
||||
});
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
||||
var 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];
|
||||
}
|
||||
|
||||
var WrappedComponent = props[typePropName];
|
||||
var registeredStyles = [cssProp];
|
||||
var className = '';
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = getRegisteredStyles(cache.registered, registeredStyles, props.className);
|
||||
} else if (props.className != null) {
|
||||
className = props.className + " ";
|
||||
}
|
||||
|
||||
var serialized = serializeStyles(registeredStyles, undefined, React.useContext(ThemeContext));
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
|
||||
var labelFromStack = props[labelPropName];
|
||||
|
||||
if (labelFromStack) {
|
||||
serialized = serializeStyles([serialized, 'label:' + labelFromStack + ';']);
|
||||
}
|
||||
}
|
||||
|
||||
className += cache.key + "-" + serialized.name;
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key) && key !== 'css' && key !== typePropName && (process.env.NODE_ENV === 'production' || key !== labelPropName)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps.ref = ref;
|
||||
newProps.className = className;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serialized: serialized,
|
||||
isStringTag: typeof WrappedComponent === 'string'
|
||||
}), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Emotion.displayName = 'EmotionCssPropInternal';
|
||||
}
|
||||
|
||||
var Emotion$1 = Emotion;
|
||||
|
||||
export { CacheProvider as C, Emotion$1 as E, ThemeContext as T, __unsafe_useEmotionCache as _, ThemeProvider as a, withTheme as b, createEmotionProps as c, hasOwn as h, isBrowser as i, useTheme as u, withEmotionCache as w };
|
||||
+278
@@ -0,0 +1,278 @@
|
||||
import * as React from 'react';
|
||||
import { useContext, forwardRef } from 'react';
|
||||
import createCache from '@emotion/cache';
|
||||
import _extends from '@babel/runtime/helpers/esm/extends';
|
||||
import weakMemoize from '@emotion/weak-memoize';
|
||||
import hoistNonReactStatics from '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js';
|
||||
import { getRegisteredStyles, registerStyles, insertStyles } from '@emotion/utils';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var isBrowser = typeof document !== 'undefined';
|
||||
var hasOwn = {}.hasOwnProperty;
|
||||
|
||||
var EmotionCacheContext = /* #__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 (process.env.NODE_ENV !== 'production') {
|
||||
EmotionCacheContext.displayName = 'EmotionCacheContext';
|
||||
}
|
||||
|
||||
var CacheProvider = EmotionCacheContext.Provider;
|
||||
var __unsafe_useEmotionCache = function useEmotionCache() {
|
||||
return useContext(EmotionCacheContext);
|
||||
};
|
||||
|
||||
var withEmotionCache = function withEmotionCache(func) {
|
||||
// $FlowFixMe
|
||||
return /*#__PURE__*/forwardRef(function (props, ref) {
|
||||
// the cache will never be null in the browser
|
||||
var cache = useContext(EmotionCacheContext);
|
||||
return func(props, cache, ref);
|
||||
});
|
||||
};
|
||||
|
||||
if (!isBrowser) {
|
||||
withEmotionCache = function withEmotionCache(func) {
|
||||
return function (props) {
|
||||
var 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 /*#__PURE__*/React.createElement(EmotionCacheContext.Provider, {
|
||||
value: cache
|
||||
}, func(props, cache));
|
||||
} else {
|
||||
return func(props, cache);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var ThemeContext = /* #__PURE__ */React.createContext({});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ThemeContext.displayName = 'EmotionThemeContext';
|
||||
}
|
||||
|
||||
var useTheme = function useTheme() {
|
||||
return React.useContext(ThemeContext);
|
||||
};
|
||||
|
||||
var getTheme = function getTheme(outerTheme, theme) {
|
||||
if (typeof theme === 'function') {
|
||||
var mergedTheme = theme(outerTheme);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && (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 (process.env.NODE_ENV !== 'production' && (theme == null || typeof theme !== 'object' || Array.isArray(theme))) {
|
||||
throw new Error('[ThemeProvider] Please make your theme prop a plain object');
|
||||
}
|
||||
|
||||
return _extends({}, outerTheme, theme);
|
||||
};
|
||||
|
||||
var createCacheWithTheme = /* #__PURE__ */weakMemoize(function (outerTheme) {
|
||||
return weakMemoize(function (theme) {
|
||||
return getTheme(outerTheme, theme);
|
||||
});
|
||||
});
|
||||
var ThemeProvider = function ThemeProvider(props) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
|
||||
if (props.theme !== theme) {
|
||||
theme = createCacheWithTheme(theme)(props.theme);
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
||||
value: theme
|
||||
}, props.children);
|
||||
};
|
||||
function withTheme(Component) {
|
||||
var componentName = Component.displayName || Component.name || 'Component';
|
||||
|
||||
var render = function render(props, ref) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
return /*#__PURE__*/React.createElement(Component, _extends({
|
||||
theme: theme,
|
||||
ref: ref
|
||||
}, props));
|
||||
}; // $FlowFixMe
|
||||
|
||||
|
||||
var WithTheme = /*#__PURE__*/React.forwardRef(render);
|
||||
WithTheme.displayName = "WithTheme(" + componentName + ")";
|
||||
return hoistNonReactStatics(WithTheme, Component);
|
||||
}
|
||||
|
||||
var getLastPart = function getLastPart(functionName) {
|
||||
// The match may be something like 'Object.createEmotionProps' or
|
||||
// 'Loader.prototype.render'
|
||||
var parts = functionName.split('.');
|
||||
return parts[parts.length - 1];
|
||||
};
|
||||
|
||||
var getFunctionNameFromStackTraceLine = function getFunctionNameFromStackTraceLine(line) {
|
||||
// V8
|
||||
var 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;
|
||||
};
|
||||
|
||||
var 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.
|
||||
|
||||
var sanitizeIdentifier = function sanitizeIdentifier(identifier) {
|
||||
return identifier.replace(/\$/g, '-');
|
||||
};
|
||||
|
||||
var getLabelFromStackTrace = function getLabelFromStackTrace(stackTrace) {
|
||||
if (!stackTrace) return undefined;
|
||||
var lines = stackTrace.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var 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;
|
||||
};
|
||||
|
||||
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
||||
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
|
||||
var createEmotionProps = function createEmotionProps(type, props) {
|
||||
if (process.env.NODE_ENV !== 'production' && 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 + "`");
|
||||
}
|
||||
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps[typePropName] = type; // For performance, only call getLabelFromStackTrace in development and when
|
||||
// the label hasn't already been computed
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !!props.css && (typeof props.css !== 'object' || typeof props.css.name !== 'string' || props.css.name.indexOf('-') === -1)) {
|
||||
var label = getLabelFromStackTrace(new Error().stack);
|
||||
if (label) newProps[labelPropName] = label;
|
||||
}
|
||||
|
||||
return newProps;
|
||||
};
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serialized = _ref.serialized,
|
||||
isStringTag = _ref.isStringTag;
|
||||
registerStyles(cache, serialized, isStringTag);
|
||||
var rules = useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
return insertStyles(cache, serialized, isStringTag);
|
||||
});
|
||||
|
||||
if (!isBrowser && rules !== undefined) {
|
||||
var _ref2;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedNames, _ref2.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
||||
var 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];
|
||||
}
|
||||
|
||||
var WrappedComponent = props[typePropName];
|
||||
var registeredStyles = [cssProp];
|
||||
var className = '';
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = getRegisteredStyles(cache.registered, registeredStyles, props.className);
|
||||
} else if (props.className != null) {
|
||||
className = props.className + " ";
|
||||
}
|
||||
|
||||
var serialized = serializeStyles(registeredStyles, undefined, React.useContext(ThemeContext));
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
|
||||
var labelFromStack = props[labelPropName];
|
||||
|
||||
if (labelFromStack) {
|
||||
serialized = serializeStyles([serialized, 'label:' + labelFromStack + ';']);
|
||||
}
|
||||
}
|
||||
|
||||
className += cache.key + "-" + serialized.name;
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key) && key !== 'css' && key !== typePropName && (process.env.NODE_ENV === 'production' || key !== labelPropName)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps.ref = ref;
|
||||
newProps.className = className;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serialized: serialized,
|
||||
isStringTag: typeof WrappedComponent === 'string'
|
||||
}), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Emotion.displayName = 'EmotionCssPropInternal';
|
||||
}
|
||||
|
||||
var Emotion$1 = Emotion;
|
||||
|
||||
export { CacheProvider as C, Emotion$1 as E, ThemeContext as T, __unsafe_useEmotionCache as _, ThemeProvider as a, withTheme as b, createEmotionProps as c, hasOwn as h, isBrowser as i, useTheme as u, withEmotionCache as w };
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var createCache = require('@emotion/cache');
|
||||
var _extends = require('@babel/runtime/helpers/extends');
|
||||
var weakMemoize = require('@emotion/weak-memoize');
|
||||
var _isolatedHnrs_dist_emotionReact_isolatedHnrs = require('../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.prod.js');
|
||||
var utils = require('@emotion/utils');
|
||||
var serialize = require('@emotion/serialize');
|
||||
var useInsertionEffectWithFallbacks = require('@emotion/use-insertion-effect-with-fallbacks');
|
||||
|
||||
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
||||
var createCache__default = /*#__PURE__*/_interopDefault(createCache);
|
||||
var weakMemoize__default = /*#__PURE__*/_interopDefault(weakMemoize);
|
||||
|
||||
var isBrowser = typeof document !== 'undefined';
|
||||
var hasOwn = {}.hasOwnProperty;
|
||||
|
||||
var EmotionCacheContext = /* #__PURE__ */React__namespace.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__default["default"]({
|
||||
key: 'css'
|
||||
}) : null);
|
||||
|
||||
var CacheProvider = EmotionCacheContext.Provider;
|
||||
var __unsafe_useEmotionCache = function useEmotionCache() {
|
||||
return React.useContext(EmotionCacheContext);
|
||||
};
|
||||
|
||||
exports.withEmotionCache = function withEmotionCache(func) {
|
||||
// $FlowFixMe
|
||||
return /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
// the cache will never be null in the browser
|
||||
var cache = React.useContext(EmotionCacheContext);
|
||||
return func(props, cache, ref);
|
||||
});
|
||||
};
|
||||
|
||||
if (!isBrowser) {
|
||||
exports.withEmotionCache = function withEmotionCache(func) {
|
||||
return function (props) {
|
||||
var cache = React.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__default["default"]({
|
||||
key: 'css'
|
||||
});
|
||||
return /*#__PURE__*/React__namespace.createElement(EmotionCacheContext.Provider, {
|
||||
value: cache
|
||||
}, func(props, cache));
|
||||
} else {
|
||||
return func(props, cache);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var ThemeContext = /* #__PURE__ */React__namespace.createContext({});
|
||||
|
||||
var useTheme = function useTheme() {
|
||||
return React__namespace.useContext(ThemeContext);
|
||||
};
|
||||
|
||||
var getTheme = function getTheme(outerTheme, theme) {
|
||||
if (typeof theme === 'function') {
|
||||
var mergedTheme = theme(outerTheme);
|
||||
|
||||
return mergedTheme;
|
||||
}
|
||||
|
||||
return _extends({}, outerTheme, theme);
|
||||
};
|
||||
|
||||
var createCacheWithTheme = /* #__PURE__ */weakMemoize__default["default"](function (outerTheme) {
|
||||
return weakMemoize__default["default"](function (theme) {
|
||||
return getTheme(outerTheme, theme);
|
||||
});
|
||||
});
|
||||
var ThemeProvider = function ThemeProvider(props) {
|
||||
var theme = React__namespace.useContext(ThemeContext);
|
||||
|
||||
if (props.theme !== theme) {
|
||||
theme = createCacheWithTheme(theme)(props.theme);
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React__namespace.createElement(ThemeContext.Provider, {
|
||||
value: theme
|
||||
}, props.children);
|
||||
};
|
||||
function withTheme(Component) {
|
||||
var componentName = Component.displayName || Component.name || 'Component';
|
||||
|
||||
var render = function render(props, ref) {
|
||||
var theme = React__namespace.useContext(ThemeContext);
|
||||
return /*#__PURE__*/React__namespace.createElement(Component, _extends({
|
||||
theme: theme,
|
||||
ref: ref
|
||||
}, props));
|
||||
}; // $FlowFixMe
|
||||
|
||||
|
||||
var WithTheme = /*#__PURE__*/React__namespace.forwardRef(render);
|
||||
WithTheme.displayName = "WithTheme(" + componentName + ")";
|
||||
return _isolatedHnrs_dist_emotionReact_isolatedHnrs["default"](WithTheme, Component);
|
||||
}
|
||||
|
||||
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
||||
var createEmotionProps = function createEmotionProps(type, props) {
|
||||
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps[typePropName] = type; // For performance, only call getLabelFromStackTrace in development and when
|
||||
|
||||
return newProps;
|
||||
};
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serialized = _ref.serialized,
|
||||
isStringTag = _ref.isStringTag;
|
||||
utils.registerStyles(cache, serialized, isStringTag);
|
||||
var rules = useInsertionEffectWithFallbacks.useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
return utils.insertStyles(cache, serialized, isStringTag);
|
||||
});
|
||||
|
||||
if (!isBrowser && rules !== undefined) {
|
||||
var _ref2;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React__namespace.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedNames, _ref2.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var Emotion = /* #__PURE__ */exports.withEmotionCache(function (props, cache, ref) {
|
||||
var 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];
|
||||
}
|
||||
|
||||
var WrappedComponent = props[typePropName];
|
||||
var registeredStyles = [cssProp];
|
||||
var className = '';
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = utils.getRegisteredStyles(cache.registered, registeredStyles, props.className);
|
||||
} else if (props.className != null) {
|
||||
className = props.className + " ";
|
||||
}
|
||||
|
||||
var serialized = serialize.serializeStyles(registeredStyles, undefined, React__namespace.useContext(ThemeContext));
|
||||
|
||||
className += cache.key + "-" + serialized.name;
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key) && key !== 'css' && key !== typePropName && ( "production" === 'production' )) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps.ref = ref;
|
||||
newProps.className = className;
|
||||
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serialized: serialized,
|
||||
isStringTag: typeof WrappedComponent === 'string'
|
||||
}), /*#__PURE__*/React__namespace.createElement(WrappedComponent, newProps));
|
||||
});
|
||||
|
||||
var Emotion$1 = Emotion;
|
||||
|
||||
exports.CacheProvider = CacheProvider;
|
||||
exports.Emotion = Emotion$1;
|
||||
exports.ThemeContext = ThemeContext;
|
||||
exports.ThemeProvider = ThemeProvider;
|
||||
exports.__unsafe_useEmotionCache = __unsafe_useEmotionCache;
|
||||
exports.createEmotionProps = createEmotionProps;
|
||||
exports.hasOwn = hasOwn;
|
||||
exports.isBrowser = isBrowser;
|
||||
exports.useTheme = useTheme;
|
||||
exports.withTheme = withTheme;
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var createCache = require('@emotion/cache');
|
||||
var _extends = require('@babel/runtime/helpers/extends');
|
||||
var weakMemoize = require('@emotion/weak-memoize');
|
||||
var _isolatedHnrs_dist_emotionReact_isolatedHnrs = require('../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.dev.js');
|
||||
var utils = require('@emotion/utils');
|
||||
var serialize = require('@emotion/serialize');
|
||||
var useInsertionEffectWithFallbacks = require('@emotion/use-insertion-effect-with-fallbacks');
|
||||
|
||||
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
||||
var createCache__default = /*#__PURE__*/_interopDefault(createCache);
|
||||
var weakMemoize__default = /*#__PURE__*/_interopDefault(weakMemoize);
|
||||
|
||||
var isBrowser = typeof document !== 'undefined';
|
||||
var hasOwn = {}.hasOwnProperty;
|
||||
|
||||
var EmotionCacheContext = /* #__PURE__ */React__namespace.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__default["default"]({
|
||||
key: 'css'
|
||||
}) : null);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
EmotionCacheContext.displayName = 'EmotionCacheContext';
|
||||
}
|
||||
|
||||
var CacheProvider = EmotionCacheContext.Provider;
|
||||
var __unsafe_useEmotionCache = function useEmotionCache() {
|
||||
return React.useContext(EmotionCacheContext);
|
||||
};
|
||||
|
||||
exports.withEmotionCache = function withEmotionCache(func) {
|
||||
// $FlowFixMe
|
||||
return /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
// the cache will never be null in the browser
|
||||
var cache = React.useContext(EmotionCacheContext);
|
||||
return func(props, cache, ref);
|
||||
});
|
||||
};
|
||||
|
||||
if (!isBrowser) {
|
||||
exports.withEmotionCache = function withEmotionCache(func) {
|
||||
return function (props) {
|
||||
var cache = React.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__default["default"]({
|
||||
key: 'css'
|
||||
});
|
||||
return /*#__PURE__*/React__namespace.createElement(EmotionCacheContext.Provider, {
|
||||
value: cache
|
||||
}, func(props, cache));
|
||||
} else {
|
||||
return func(props, cache);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var ThemeContext = /* #__PURE__ */React__namespace.createContext({});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ThemeContext.displayName = 'EmotionThemeContext';
|
||||
}
|
||||
|
||||
var useTheme = function useTheme() {
|
||||
return React__namespace.useContext(ThemeContext);
|
||||
};
|
||||
|
||||
var getTheme = function getTheme(outerTheme, theme) {
|
||||
if (typeof theme === 'function') {
|
||||
var mergedTheme = theme(outerTheme);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && (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 (process.env.NODE_ENV !== 'production' && (theme == null || typeof theme !== 'object' || Array.isArray(theme))) {
|
||||
throw new Error('[ThemeProvider] Please make your theme prop a plain object');
|
||||
}
|
||||
|
||||
return _extends({}, outerTheme, theme);
|
||||
};
|
||||
|
||||
var createCacheWithTheme = /* #__PURE__ */weakMemoize__default["default"](function (outerTheme) {
|
||||
return weakMemoize__default["default"](function (theme) {
|
||||
return getTheme(outerTheme, theme);
|
||||
});
|
||||
});
|
||||
var ThemeProvider = function ThemeProvider(props) {
|
||||
var theme = React__namespace.useContext(ThemeContext);
|
||||
|
||||
if (props.theme !== theme) {
|
||||
theme = createCacheWithTheme(theme)(props.theme);
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React__namespace.createElement(ThemeContext.Provider, {
|
||||
value: theme
|
||||
}, props.children);
|
||||
};
|
||||
function withTheme(Component) {
|
||||
var componentName = Component.displayName || Component.name || 'Component';
|
||||
|
||||
var render = function render(props, ref) {
|
||||
var theme = React__namespace.useContext(ThemeContext);
|
||||
return /*#__PURE__*/React__namespace.createElement(Component, _extends({
|
||||
theme: theme,
|
||||
ref: ref
|
||||
}, props));
|
||||
}; // $FlowFixMe
|
||||
|
||||
|
||||
var WithTheme = /*#__PURE__*/React__namespace.forwardRef(render);
|
||||
WithTheme.displayName = "WithTheme(" + componentName + ")";
|
||||
return _isolatedHnrs_dist_emotionReact_isolatedHnrs["default"](WithTheme, Component);
|
||||
}
|
||||
|
||||
var getLastPart = function getLastPart(functionName) {
|
||||
// The match may be something like 'Object.createEmotionProps' or
|
||||
// 'Loader.prototype.render'
|
||||
var parts = functionName.split('.');
|
||||
return parts[parts.length - 1];
|
||||
};
|
||||
|
||||
var getFunctionNameFromStackTraceLine = function getFunctionNameFromStackTraceLine(line) {
|
||||
// V8
|
||||
var 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;
|
||||
};
|
||||
|
||||
var 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.
|
||||
|
||||
var sanitizeIdentifier = function sanitizeIdentifier(identifier) {
|
||||
return identifier.replace(/\$/g, '-');
|
||||
};
|
||||
|
||||
var getLabelFromStackTrace = function getLabelFromStackTrace(stackTrace) {
|
||||
if (!stackTrace) return undefined;
|
||||
var lines = stackTrace.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var 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;
|
||||
};
|
||||
|
||||
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
||||
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
|
||||
var createEmotionProps = function createEmotionProps(type, props) {
|
||||
if (process.env.NODE_ENV !== 'production' && 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 + "`");
|
||||
}
|
||||
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps[typePropName] = type; // For performance, only call getLabelFromStackTrace in development and when
|
||||
// the label hasn't already been computed
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !!props.css && (typeof props.css !== 'object' || typeof props.css.name !== 'string' || props.css.name.indexOf('-') === -1)) {
|
||||
var label = getLabelFromStackTrace(new Error().stack);
|
||||
if (label) newProps[labelPropName] = label;
|
||||
}
|
||||
|
||||
return newProps;
|
||||
};
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serialized = _ref.serialized,
|
||||
isStringTag = _ref.isStringTag;
|
||||
utils.registerStyles(cache, serialized, isStringTag);
|
||||
var rules = useInsertionEffectWithFallbacks.useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
return utils.insertStyles(cache, serialized, isStringTag);
|
||||
});
|
||||
|
||||
if (!isBrowser && rules !== undefined) {
|
||||
var _ref2;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React__namespace.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedNames, _ref2.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var Emotion = /* #__PURE__ */exports.withEmotionCache(function (props, cache, ref) {
|
||||
var 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];
|
||||
}
|
||||
|
||||
var WrappedComponent = props[typePropName];
|
||||
var registeredStyles = [cssProp];
|
||||
var className = '';
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = utils.getRegisteredStyles(cache.registered, registeredStyles, props.className);
|
||||
} else if (props.className != null) {
|
||||
className = props.className + " ";
|
||||
}
|
||||
|
||||
var serialized = serialize.serializeStyles(registeredStyles, undefined, React__namespace.useContext(ThemeContext));
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
|
||||
var labelFromStack = props[labelPropName];
|
||||
|
||||
if (labelFromStack) {
|
||||
serialized = serialize.serializeStyles([serialized, 'label:' + labelFromStack + ';']);
|
||||
}
|
||||
}
|
||||
|
||||
className += cache.key + "-" + serialized.name;
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key) && key !== 'css' && key !== typePropName && (process.env.NODE_ENV === 'production' || key !== labelPropName)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps.ref = ref;
|
||||
newProps.className = className;
|
||||
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serialized: serialized,
|
||||
isStringTag: typeof WrappedComponent === 'string'
|
||||
}), /*#__PURE__*/React__namespace.createElement(WrappedComponent, newProps));
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Emotion.displayName = 'EmotionCssPropInternal';
|
||||
}
|
||||
|
||||
var Emotion$1 = Emotion;
|
||||
|
||||
exports.CacheProvider = CacheProvider;
|
||||
exports.Emotion = Emotion$1;
|
||||
exports.ThemeContext = ThemeContext;
|
||||
exports.ThemeProvider = ThemeProvider;
|
||||
exports.__unsafe_useEmotionCache = __unsafe_useEmotionCache;
|
||||
exports.createEmotionProps = createEmotionProps;
|
||||
exports.hasOwn = hasOwn;
|
||||
exports.isBrowser = isBrowser;
|
||||
exports.useTheme = useTheme;
|
||||
exports.withTheme = withTheme;
|
||||
+442
@@ -0,0 +1,442 @@
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps, w as withEmotionCache, T as ThemeContext, i as isBrowser$1 } from './emotion-element-43c6fea0.browser.esm.js';
|
||||
export { C as CacheProvider, T as ThemeContext, a as ThemeProvider, _ as __unsafe_useEmotionCache, u as useTheme, w as withEmotionCache, b as withTheme } from './emotion-element-43c6fea0.browser.esm.js';
|
||||
import * as React from 'react';
|
||||
import { insertStyles, registerStyles, getRegisteredStyles } from '@emotion/utils';
|
||||
import { useInsertionEffectWithLayoutFallback, useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
|
||||
var pkg = {
|
||||
name: "@emotion/react",
|
||||
version: "11.11.4",
|
||||
main: "dist/emotion-react.cjs.js",
|
||||
module: "dist/emotion-react.esm.js",
|
||||
browser: {
|
||||
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
|
||||
},
|
||||
exports: {
|
||||
".": {
|
||||
module: {
|
||||
worker: "./dist/emotion-react.worker.esm.js",
|
||||
browser: "./dist/emotion-react.browser.esm.js",
|
||||
"default": "./dist/emotion-react.esm.js"
|
||||
},
|
||||
"import": "./dist/emotion-react.cjs.mjs",
|
||||
"default": "./dist/emotion-react.cjs.js"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
|
||||
browser: "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
|
||||
},
|
||||
"./_isolated-hnrs": {
|
||||
module: {
|
||||
worker: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
|
||||
browser: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
|
||||
},
|
||||
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
|
||||
browser: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
},
|
||||
types: "types/index.d.ts",
|
||||
files: [
|
||||
"src",
|
||||
"dist",
|
||||
"jsx-runtime",
|
||||
"jsx-dev-runtime",
|
||||
"_isolated-hnrs",
|
||||
"types/*.d.ts",
|
||||
"macro.*"
|
||||
],
|
||||
sideEffects: false,
|
||||
author: "Emotion Contributors",
|
||||
license: "MIT",
|
||||
scripts: {
|
||||
"test:typescript": "dtslint types"
|
||||
},
|
||||
dependencies: {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@emotion/babel-plugin": "^11.11.0",
|
||||
"@emotion/cache": "^11.11.0",
|
||||
"@emotion/serialize": "^1.1.3",
|
||||
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
|
||||
"@emotion/utils": "^1.2.1",
|
||||
"@emotion/weak-memoize": "^0.3.1",
|
||||
"hoist-non-react-statics": "^3.3.1"
|
||||
},
|
||||
peerDependencies: {
|
||||
react: ">=16.8.0"
|
||||
},
|
||||
peerDependenciesMeta: {
|
||||
"@types/react": {
|
||||
optional: true
|
||||
}
|
||||
},
|
||||
devDependencies: {
|
||||
"@definitelytyped/dtslint": "0.0.112",
|
||||
"@emotion/css": "11.11.2",
|
||||
"@emotion/css-prettifier": "1.1.3",
|
||||
"@emotion/server": "11.11.0",
|
||||
"@emotion/styled": "11.11.0",
|
||||
"html-tag-names": "^1.1.2",
|
||||
react: "16.14.0",
|
||||
"svg-tag-names": "^1.1.1",
|
||||
typescript: "^4.5.5"
|
||||
},
|
||||
repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
|
||||
publishConfig: {
|
||||
access: "public"
|
||||
},
|
||||
"umd:main": "dist/emotion-react.umd.min.js",
|
||||
preconstruct: {
|
||||
entrypoints: [
|
||||
"./index.js",
|
||||
"./jsx-runtime.js",
|
||||
"./jsx-dev-runtime.js",
|
||||
"./_isolated-hnrs.js"
|
||||
],
|
||||
umdName: "emotionReact",
|
||||
exports: {
|
||||
envConditions: [
|
||||
"browser",
|
||||
"worker"
|
||||
],
|
||||
extra: {
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var jsx = function jsx(type, props) {
|
||||
var args = arguments;
|
||||
|
||||
if (props == null || !hasOwn.call(props, 'css')) {
|
||||
// $FlowFixMe
|
||||
return React.createElement.apply(undefined, args);
|
||||
}
|
||||
|
||||
var argsLength = args.length;
|
||||
var createElementArgArray = new Array(argsLength);
|
||||
createElementArgArray[0] = Emotion;
|
||||
createElementArgArray[1] = createEmotionProps(type, props);
|
||||
|
||||
for (var i = 2; i < argsLength; i++) {
|
||||
createElementArgArray[i] = args[i];
|
||||
} // $FlowFixMe
|
||||
|
||||
|
||||
return React.createElement.apply(null, createElementArgArray);
|
||||
};
|
||||
|
||||
var 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
|
||||
|
||||
var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
if (process.env.NODE_ENV !== 'production' && !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
|
||||
// $FlowFixMe 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;
|
||||
}
|
||||
|
||||
var styles = props.styles;
|
||||
var serialized = serializeStyles([styles], undefined, React.useContext(ThemeContext));
|
||||
|
||||
if (!isBrowser$1) {
|
||||
var _ref;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var serializedStyles = serialized.styles;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
serializedStyles += next.styles;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
var shouldCache = cache.compat === true;
|
||||
var rules = cache.insert("", {
|
||||
name: serializedNames,
|
||||
styles: serializedStyles
|
||||
}, cache.sheet, shouldCache);
|
||||
|
||||
if (shouldCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement("style", (_ref = {}, _ref["data-emotion"] = cache.key + "-global " + serializedNames, _ref.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref.nonce = cache.sheet.nonce, _ref));
|
||||
} // 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
|
||||
|
||||
|
||||
var sheetRef = React.useRef();
|
||||
useInsertionEffectWithLayoutFallback(function () {
|
||||
var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
|
||||
|
||||
var sheet = new cache.sheet.constructor({
|
||||
key: key,
|
||||
nonce: cache.sheet.nonce,
|
||||
container: cache.sheet.container,
|
||||
speedy: cache.sheet.isSpeedy
|
||||
});
|
||||
var rehydrating = false; // $FlowFixMe
|
||||
|
||||
var node = 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 function () {
|
||||
sheet.flush();
|
||||
};
|
||||
}, [cache]);
|
||||
useInsertionEffectWithLayoutFallback(function () {
|
||||
var sheetRefCurrent = sheetRef.current;
|
||||
var sheet = sheetRefCurrent[0],
|
||||
rehydrating = sheetRefCurrent[1];
|
||||
|
||||
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
|
||||
var element = sheet.tags[sheet.tags.length - 1].nextElementSibling;
|
||||
sheet.before = element;
|
||||
sheet.flush();
|
||||
}
|
||||
|
||||
cache.insert("", serialized, sheet, false);
|
||||
}, [cache, serialized.name]);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Global.displayName = 'EmotionGlobal';
|
||||
}
|
||||
|
||||
function css() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return serializeStyles(args);
|
||||
}
|
||||
|
||||
var keyframes = function keyframes() {
|
||||
var insertable = css.apply(void 0, arguments);
|
||||
var name = "animation-" + insertable.name; // $FlowFixMe
|
||||
|
||||
return {
|
||||
name: name,
|
||||
styles: "@keyframes " + name + "{" + insertable.styles + "}",
|
||||
anim: 1,
|
||||
toString: function toString() {
|
||||
return "_EMO_" + this.name + "_" + this.styles + "_EMO_";
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var classnames = function classnames(args) {
|
||||
var len = args.length;
|
||||
var i = 0;
|
||||
var cls = '';
|
||||
|
||||
for (; i < len; i++) {
|
||||
var arg = args[i];
|
||||
if (arg == null) continue;
|
||||
var toAdd = void 0;
|
||||
|
||||
switch (typeof arg) {
|
||||
case 'boolean':
|
||||
break;
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (Array.isArray(arg)) {
|
||||
toAdd = classnames(arg);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && 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 (var 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, css, className) {
|
||||
var registeredStyles = [];
|
||||
var rawClassName = getRegisteredStyles(registered, registeredStyles, className);
|
||||
|
||||
if (registeredStyles.length < 2) {
|
||||
return className;
|
||||
}
|
||||
|
||||
return rawClassName + css(registeredStyles);
|
||||
}
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serializedArr = _ref.serializedArr;
|
||||
useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
|
||||
for (var i = 0; i < serializedArr.length; i++) {
|
||||
insertStyles(cache, serializedArr[i], false);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
var hasRendered = false;
|
||||
var serializedArr = [];
|
||||
|
||||
var css = function css() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error('css can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var 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;
|
||||
};
|
||||
|
||||
var cx = function cx() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error('cx can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return merge(cache.registered, css, classnames(args));
|
||||
};
|
||||
|
||||
var content = {
|
||||
css: css,
|
||||
cx: cx,
|
||||
theme: React.useContext(ThemeContext)
|
||||
};
|
||||
var ele = props.children(content);
|
||||
hasRendered = true;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serializedArr: serializedArr
|
||||
}), ele);
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ClassNames.displayName = 'EmotionClassNames';
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var isBrowser = "object" !== 'undefined'; // #1727, #2905 for some reason Jest and Vitest evaluate modules twice if some consuming module gets mocked
|
||||
|
||||
var 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
|
||||
var globalContext = // $FlowIgnore
|
||||
typeof globalThis !== 'undefined' ? globalThis // eslint-disable-line no-undef
|
||||
: isBrowser ? window : global;
|
||||
var 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;
|
||||
}
|
||||
}
|
||||
|
||||
export { ClassNames, Global, jsx as createElement, css, jsx, keyframes };
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from "./declarations/src/index.js";
|
||||
//# sourceMappingURL=emotion-react.cjs.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react.cjs.d.mts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from "./declarations/src/index";
|
||||
//# sourceMappingURL=emotion-react.cjs.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
|
||||
+499
@@ -0,0 +1,499 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var emotionElement = require('./emotion-element-f93e57b0.cjs.dev.js');
|
||||
var React = require('react');
|
||||
var utils = require('@emotion/utils');
|
||||
var useInsertionEffectWithFallbacks = require('@emotion/use-insertion-effect-with-fallbacks');
|
||||
var serialize = require('@emotion/serialize');
|
||||
require('@emotion/cache');
|
||||
require('@babel/runtime/helpers/extends');
|
||||
require('@emotion/weak-memoize');
|
||||
require('../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.dev.js');
|
||||
require('hoist-non-react-statics');
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
||||
|
||||
var pkg = {
|
||||
name: "@emotion/react",
|
||||
version: "11.11.4",
|
||||
main: "dist/emotion-react.cjs.js",
|
||||
module: "dist/emotion-react.esm.js",
|
||||
browser: {
|
||||
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
|
||||
},
|
||||
exports: {
|
||||
".": {
|
||||
module: {
|
||||
worker: "./dist/emotion-react.worker.esm.js",
|
||||
browser: "./dist/emotion-react.browser.esm.js",
|
||||
"default": "./dist/emotion-react.esm.js"
|
||||
},
|
||||
"import": "./dist/emotion-react.cjs.mjs",
|
||||
"default": "./dist/emotion-react.cjs.js"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
|
||||
browser: "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
|
||||
},
|
||||
"./_isolated-hnrs": {
|
||||
module: {
|
||||
worker: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
|
||||
browser: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
|
||||
},
|
||||
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
|
||||
browser: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
},
|
||||
types: "types/index.d.ts",
|
||||
files: [
|
||||
"src",
|
||||
"dist",
|
||||
"jsx-runtime",
|
||||
"jsx-dev-runtime",
|
||||
"_isolated-hnrs",
|
||||
"types/*.d.ts",
|
||||
"macro.*"
|
||||
],
|
||||
sideEffects: false,
|
||||
author: "Emotion Contributors",
|
||||
license: "MIT",
|
||||
scripts: {
|
||||
"test:typescript": "dtslint types"
|
||||
},
|
||||
dependencies: {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@emotion/babel-plugin": "^11.11.0",
|
||||
"@emotion/cache": "^11.11.0",
|
||||
"@emotion/serialize": "^1.1.3",
|
||||
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
|
||||
"@emotion/utils": "^1.2.1",
|
||||
"@emotion/weak-memoize": "^0.3.1",
|
||||
"hoist-non-react-statics": "^3.3.1"
|
||||
},
|
||||
peerDependencies: {
|
||||
react: ">=16.8.0"
|
||||
},
|
||||
peerDependenciesMeta: {
|
||||
"@types/react": {
|
||||
optional: true
|
||||
}
|
||||
},
|
||||
devDependencies: {
|
||||
"@definitelytyped/dtslint": "0.0.112",
|
||||
"@emotion/css": "11.11.2",
|
||||
"@emotion/css-prettifier": "1.1.3",
|
||||
"@emotion/server": "11.11.0",
|
||||
"@emotion/styled": "11.11.0",
|
||||
"html-tag-names": "^1.1.2",
|
||||
react: "16.14.0",
|
||||
"svg-tag-names": "^1.1.1",
|
||||
typescript: "^4.5.5"
|
||||
},
|
||||
repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
|
||||
publishConfig: {
|
||||
access: "public"
|
||||
},
|
||||
"umd:main": "dist/emotion-react.umd.min.js",
|
||||
preconstruct: {
|
||||
entrypoints: [
|
||||
"./index.js",
|
||||
"./jsx-runtime.js",
|
||||
"./jsx-dev-runtime.js",
|
||||
"./_isolated-hnrs.js"
|
||||
],
|
||||
umdName: "emotionReact",
|
||||
exports: {
|
||||
envConditions: [
|
||||
"browser",
|
||||
"worker"
|
||||
],
|
||||
extra: {
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var jsx = function jsx(type, props) {
|
||||
var args = arguments;
|
||||
|
||||
if (props == null || !emotionElement.hasOwn.call(props, 'css')) {
|
||||
// $FlowFixMe
|
||||
return React__namespace.createElement.apply(undefined, args);
|
||||
}
|
||||
|
||||
var argsLength = args.length;
|
||||
var createElementArgArray = new Array(argsLength);
|
||||
createElementArgArray[0] = emotionElement.Emotion;
|
||||
createElementArgArray[1] = emotionElement.createEmotionProps(type, props);
|
||||
|
||||
for (var i = 2; i < argsLength; i++) {
|
||||
createElementArgArray[i] = args[i];
|
||||
} // $FlowFixMe
|
||||
|
||||
|
||||
return React__namespace.createElement.apply(null, createElementArgArray);
|
||||
};
|
||||
|
||||
var 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
|
||||
|
||||
var Global = /* #__PURE__ */emotionElement.withEmotionCache(function (props, cache) {
|
||||
if (process.env.NODE_ENV !== 'production' && !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
|
||||
// $FlowFixMe 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;
|
||||
}
|
||||
|
||||
var styles = props.styles;
|
||||
var serialized = serialize.serializeStyles([styles], undefined, React__namespace.useContext(emotionElement.ThemeContext));
|
||||
|
||||
if (!emotionElement.isBrowser) {
|
||||
var _ref;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var serializedStyles = serialized.styles;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
serializedStyles += next.styles;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
var shouldCache = cache.compat === true;
|
||||
var rules = cache.insert("", {
|
||||
name: serializedNames,
|
||||
styles: serializedStyles
|
||||
}, cache.sheet, shouldCache);
|
||||
|
||||
if (shouldCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React__namespace.createElement("style", (_ref = {}, _ref["data-emotion"] = cache.key + "-global " + serializedNames, _ref.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref.nonce = cache.sheet.nonce, _ref));
|
||||
} // 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
|
||||
|
||||
|
||||
var sheetRef = React__namespace.useRef();
|
||||
useInsertionEffectWithFallbacks.useInsertionEffectWithLayoutFallback(function () {
|
||||
var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
|
||||
|
||||
var sheet = new cache.sheet.constructor({
|
||||
key: key,
|
||||
nonce: cache.sheet.nonce,
|
||||
container: cache.sheet.container,
|
||||
speedy: cache.sheet.isSpeedy
|
||||
});
|
||||
var rehydrating = false; // $FlowFixMe
|
||||
|
||||
var node = 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 function () {
|
||||
sheet.flush();
|
||||
};
|
||||
}, [cache]);
|
||||
useInsertionEffectWithFallbacks.useInsertionEffectWithLayoutFallback(function () {
|
||||
var sheetRefCurrent = sheetRef.current;
|
||||
var sheet = sheetRefCurrent[0],
|
||||
rehydrating = sheetRefCurrent[1];
|
||||
|
||||
if (rehydrating) {
|
||||
sheetRefCurrent[1] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (serialized.next !== undefined) {
|
||||
// insert keyframes
|
||||
utils.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
|
||||
var element = sheet.tags[sheet.tags.length - 1].nextElementSibling;
|
||||
sheet.before = element;
|
||||
sheet.flush();
|
||||
}
|
||||
|
||||
cache.insert("", serialized, sheet, false);
|
||||
}, [cache, serialized.name]);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Global.displayName = 'EmotionGlobal';
|
||||
}
|
||||
|
||||
function css() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return serialize.serializeStyles(args);
|
||||
}
|
||||
|
||||
var keyframes = function keyframes() {
|
||||
var insertable = css.apply(void 0, arguments);
|
||||
var name = "animation-" + insertable.name; // $FlowFixMe
|
||||
|
||||
return {
|
||||
name: name,
|
||||
styles: "@keyframes " + name + "{" + insertable.styles + "}",
|
||||
anim: 1,
|
||||
toString: function toString() {
|
||||
return "_EMO_" + this.name + "_" + this.styles + "_EMO_";
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var classnames = function classnames(args) {
|
||||
var len = args.length;
|
||||
var i = 0;
|
||||
var cls = '';
|
||||
|
||||
for (; i < len; i++) {
|
||||
var arg = args[i];
|
||||
if (arg == null) continue;
|
||||
var toAdd = void 0;
|
||||
|
||||
switch (typeof arg) {
|
||||
case 'boolean':
|
||||
break;
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (Array.isArray(arg)) {
|
||||
toAdd = classnames(arg);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && 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 (var 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, css, className) {
|
||||
var registeredStyles = [];
|
||||
var rawClassName = utils.getRegisteredStyles(registered, registeredStyles, className);
|
||||
|
||||
if (registeredStyles.length < 2) {
|
||||
return className;
|
||||
}
|
||||
|
||||
return rawClassName + css(registeredStyles);
|
||||
}
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serializedArr = _ref.serializedArr;
|
||||
var rules = useInsertionEffectWithFallbacks.useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
var rules = '';
|
||||
|
||||
for (var i = 0; i < serializedArr.length; i++) {
|
||||
var res = utils.insertStyles(cache, serializedArr[i], false);
|
||||
|
||||
if (!emotionElement.isBrowser && res !== undefined) {
|
||||
rules += res;
|
||||
}
|
||||
}
|
||||
|
||||
if (!emotionElement.isBrowser) {
|
||||
return rules;
|
||||
}
|
||||
});
|
||||
|
||||
if (!emotionElement.isBrowser && rules.length !== 0) {
|
||||
var _ref2;
|
||||
|
||||
return /*#__PURE__*/React__namespace.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedArr.map(function (serialized) {
|
||||
return serialized.name;
|
||||
}).join(' '), _ref2.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var ClassNames = /* #__PURE__ */emotionElement.withEmotionCache(function (props, cache) {
|
||||
var hasRendered = false;
|
||||
var serializedArr = [];
|
||||
|
||||
var css = function css() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error('css can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var serialized = serialize.serializeStyles(args, cache.registered);
|
||||
serializedArr.push(serialized); // registration has to happen here as the result of this might get consumed by `cx`
|
||||
|
||||
utils.registerStyles(cache, serialized, false);
|
||||
return cache.key + "-" + serialized.name;
|
||||
};
|
||||
|
||||
var cx = function cx() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error('cx can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return merge(cache.registered, css, classnames(args));
|
||||
};
|
||||
|
||||
var content = {
|
||||
css: css,
|
||||
cx: cx,
|
||||
theme: React__namespace.useContext(emotionElement.ThemeContext)
|
||||
};
|
||||
var ele = props.children(content);
|
||||
hasRendered = true;
|
||||
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serializedArr: serializedArr
|
||||
}), ele);
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ClassNames.displayName = 'EmotionClassNames';
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var isBrowser = typeof document !== 'undefined'; // #1727, #2905 for some reason Jest and Vitest evaluate modules twice if some consuming module gets mocked
|
||||
|
||||
var 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
|
||||
var globalContext = // $FlowIgnore
|
||||
typeof globalThis !== 'undefined' ? globalThis // eslint-disable-line no-undef
|
||||
: isBrowser ? window : global;
|
||||
var 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;
|
||||
}
|
||||
}
|
||||
|
||||
exports.CacheProvider = emotionElement.CacheProvider;
|
||||
exports.ThemeContext = emotionElement.ThemeContext;
|
||||
exports.ThemeProvider = emotionElement.ThemeProvider;
|
||||
exports.__unsafe_useEmotionCache = emotionElement.__unsafe_useEmotionCache;
|
||||
exports.useTheme = emotionElement.useTheme;
|
||||
Object.defineProperty(exports, 'withEmotionCache', {
|
||||
enumerable: true,
|
||||
get: function () { return emotionElement.withEmotionCache; }
|
||||
});
|
||||
exports.withTheme = emotionElement.withTheme;
|
||||
exports.ClassNames = ClassNames;
|
||||
exports.Global = Global;
|
||||
exports.createElement = jsx;
|
||||
exports.css = css;
|
||||
exports.jsx = jsx;
|
||||
exports.keyframes = keyframes;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
module.exports = require("./emotion-react.cjs.prod.js");
|
||||
} else {
|
||||
module.exports = require("./emotion-react.cjs.dev.js");
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
export * from "../src/index.js";
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
export {
|
||||
CacheProvider,
|
||||
ClassNames,
|
||||
Global,
|
||||
ThemeContext,
|
||||
ThemeProvider,
|
||||
__unsafe_useEmotionCache,
|
||||
createElement,
|
||||
css,
|
||||
jsx,
|
||||
keyframes,
|
||||
useTheme,
|
||||
withEmotionCache,
|
||||
withTheme
|
||||
} from "./emotion-react.cjs.js";
|
||||
+327
@@ -0,0 +1,327 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var emotionElement = require('./emotion-element-eec0d725.cjs.prod.js');
|
||||
var React = require('react');
|
||||
var utils = require('@emotion/utils');
|
||||
var useInsertionEffectWithFallbacks = require('@emotion/use-insertion-effect-with-fallbacks');
|
||||
var serialize = require('@emotion/serialize');
|
||||
require('@emotion/cache');
|
||||
require('@babel/runtime/helpers/extends');
|
||||
require('@emotion/weak-memoize');
|
||||
require('../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.prod.js');
|
||||
require('hoist-non-react-statics');
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
||||
|
||||
var jsx = function jsx(type, props) {
|
||||
var args = arguments;
|
||||
|
||||
if (props == null || !emotionElement.hasOwn.call(props, 'css')) {
|
||||
// $FlowFixMe
|
||||
return React__namespace.createElement.apply(undefined, args);
|
||||
}
|
||||
|
||||
var argsLength = args.length;
|
||||
var createElementArgArray = new Array(argsLength);
|
||||
createElementArgArray[0] = emotionElement.Emotion;
|
||||
createElementArgArray[1] = emotionElement.createEmotionProps(type, props);
|
||||
|
||||
for (var i = 2; i < argsLength; i++) {
|
||||
createElementArgArray[i] = args[i];
|
||||
} // $FlowFixMe
|
||||
|
||||
|
||||
return React__namespace.createElement.apply(null, createElementArgArray);
|
||||
};
|
||||
|
||||
// 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
|
||||
|
||||
var Global = /* #__PURE__ */emotionElement.withEmotionCache(function (props, cache) {
|
||||
|
||||
var styles = props.styles;
|
||||
var serialized = serialize.serializeStyles([styles], undefined, React__namespace.useContext(emotionElement.ThemeContext));
|
||||
|
||||
if (!emotionElement.isBrowser) {
|
||||
var _ref;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var serializedStyles = serialized.styles;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
serializedStyles += next.styles;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
var shouldCache = cache.compat === true;
|
||||
var rules = cache.insert("", {
|
||||
name: serializedNames,
|
||||
styles: serializedStyles
|
||||
}, cache.sheet, shouldCache);
|
||||
|
||||
if (shouldCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React__namespace.createElement("style", (_ref = {}, _ref["data-emotion"] = cache.key + "-global " + serializedNames, _ref.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref.nonce = cache.sheet.nonce, _ref));
|
||||
} // 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
|
||||
|
||||
|
||||
var sheetRef = React__namespace.useRef();
|
||||
useInsertionEffectWithFallbacks.useInsertionEffectWithLayoutFallback(function () {
|
||||
var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
|
||||
|
||||
var sheet = new cache.sheet.constructor({
|
||||
key: key,
|
||||
nonce: cache.sheet.nonce,
|
||||
container: cache.sheet.container,
|
||||
speedy: cache.sheet.isSpeedy
|
||||
});
|
||||
var rehydrating = false; // $FlowFixMe
|
||||
|
||||
var node = 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 function () {
|
||||
sheet.flush();
|
||||
};
|
||||
}, [cache]);
|
||||
useInsertionEffectWithFallbacks.useInsertionEffectWithLayoutFallback(function () {
|
||||
var sheetRefCurrent = sheetRef.current;
|
||||
var sheet = sheetRefCurrent[0],
|
||||
rehydrating = sheetRefCurrent[1];
|
||||
|
||||
if (rehydrating) {
|
||||
sheetRefCurrent[1] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (serialized.next !== undefined) {
|
||||
// insert keyframes
|
||||
utils.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
|
||||
var element = sheet.tags[sheet.tags.length - 1].nextElementSibling;
|
||||
sheet.before = element;
|
||||
sheet.flush();
|
||||
}
|
||||
|
||||
cache.insert("", serialized, sheet, false);
|
||||
}, [cache, serialized.name]);
|
||||
return null;
|
||||
});
|
||||
|
||||
function css() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return serialize.serializeStyles(args);
|
||||
}
|
||||
|
||||
var keyframes = function keyframes() {
|
||||
var insertable = css.apply(void 0, arguments);
|
||||
var name = "animation-" + insertable.name; // $FlowFixMe
|
||||
|
||||
return {
|
||||
name: name,
|
||||
styles: "@keyframes " + name + "{" + insertable.styles + "}",
|
||||
anim: 1,
|
||||
toString: function toString() {
|
||||
return "_EMO_" + this.name + "_" + this.styles + "_EMO_";
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var classnames = function classnames(args) {
|
||||
var len = args.length;
|
||||
var i = 0;
|
||||
var cls = '';
|
||||
|
||||
for (; i < len; i++) {
|
||||
var arg = args[i];
|
||||
if (arg == null) continue;
|
||||
var toAdd = void 0;
|
||||
|
||||
switch (typeof arg) {
|
||||
case 'boolean':
|
||||
break;
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (Array.isArray(arg)) {
|
||||
toAdd = classnames(arg);
|
||||
} else {
|
||||
|
||||
toAdd = '';
|
||||
|
||||
for (var 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, css, className) {
|
||||
var registeredStyles = [];
|
||||
var rawClassName = utils.getRegisteredStyles(registered, registeredStyles, className);
|
||||
|
||||
if (registeredStyles.length < 2) {
|
||||
return className;
|
||||
}
|
||||
|
||||
return rawClassName + css(registeredStyles);
|
||||
}
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serializedArr = _ref.serializedArr;
|
||||
var rules = useInsertionEffectWithFallbacks.useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
var rules = '';
|
||||
|
||||
for (var i = 0; i < serializedArr.length; i++) {
|
||||
var res = utils.insertStyles(cache, serializedArr[i], false);
|
||||
|
||||
if (!emotionElement.isBrowser && res !== undefined) {
|
||||
rules += res;
|
||||
}
|
||||
}
|
||||
|
||||
if (!emotionElement.isBrowser) {
|
||||
return rules;
|
||||
}
|
||||
});
|
||||
|
||||
if (!emotionElement.isBrowser && rules.length !== 0) {
|
||||
var _ref2;
|
||||
|
||||
return /*#__PURE__*/React__namespace.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedArr.map(function (serialized) {
|
||||
return serialized.name;
|
||||
}).join(' '), _ref2.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var ClassNames = /* #__PURE__ */emotionElement.withEmotionCache(function (props, cache) {
|
||||
var hasRendered = false;
|
||||
var serializedArr = [];
|
||||
|
||||
var css = function css() {
|
||||
if (hasRendered && "production" !== 'production') {
|
||||
throw new Error('css can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var serialized = serialize.serializeStyles(args, cache.registered);
|
||||
serializedArr.push(serialized); // registration has to happen here as the result of this might get consumed by `cx`
|
||||
|
||||
utils.registerStyles(cache, serialized, false);
|
||||
return cache.key + "-" + serialized.name;
|
||||
};
|
||||
|
||||
var cx = function cx() {
|
||||
if (hasRendered && "production" !== 'production') {
|
||||
throw new Error('cx can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return merge(cache.registered, css, classnames(args));
|
||||
};
|
||||
|
||||
var content = {
|
||||
css: css,
|
||||
cx: cx,
|
||||
theme: React__namespace.useContext(emotionElement.ThemeContext)
|
||||
};
|
||||
var ele = props.children(content);
|
||||
hasRendered = true;
|
||||
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serializedArr: serializedArr
|
||||
}), ele);
|
||||
});
|
||||
|
||||
exports.CacheProvider = emotionElement.CacheProvider;
|
||||
exports.ThemeContext = emotionElement.ThemeContext;
|
||||
exports.ThemeProvider = emotionElement.ThemeProvider;
|
||||
exports.__unsafe_useEmotionCache = emotionElement.__unsafe_useEmotionCache;
|
||||
exports.useTheme = emotionElement.useTheme;
|
||||
Object.defineProperty(exports, 'withEmotionCache', {
|
||||
enumerable: true,
|
||||
get: function () { return emotionElement.withEmotionCache; }
|
||||
});
|
||||
exports.withTheme = emotionElement.withTheme;
|
||||
exports.ClassNames = ClassNames;
|
||||
exports.Global = Global;
|
||||
exports.createElement = jsx;
|
||||
exports.css = css;
|
||||
exports.jsx = jsx;
|
||||
exports.keyframes = keyframes;
|
||||
+461
@@ -0,0 +1,461 @@
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps, w as withEmotionCache, T as ThemeContext, i as isBrowser$1 } from './emotion-element-c16c303e.esm.js';
|
||||
export { C as CacheProvider, T as ThemeContext, a as ThemeProvider, _ as __unsafe_useEmotionCache, u as useTheme, w as withEmotionCache, b as withTheme } from './emotion-element-c16c303e.esm.js';
|
||||
import * as React from 'react';
|
||||
import { insertStyles, registerStyles, getRegisteredStyles } from '@emotion/utils';
|
||||
import { useInsertionEffectWithLayoutFallback, useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
|
||||
var pkg = {
|
||||
name: "@emotion/react",
|
||||
version: "11.11.4",
|
||||
main: "dist/emotion-react.cjs.js",
|
||||
module: "dist/emotion-react.esm.js",
|
||||
browser: {
|
||||
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
|
||||
},
|
||||
exports: {
|
||||
".": {
|
||||
module: {
|
||||
worker: "./dist/emotion-react.worker.esm.js",
|
||||
browser: "./dist/emotion-react.browser.esm.js",
|
||||
"default": "./dist/emotion-react.esm.js"
|
||||
},
|
||||
"import": "./dist/emotion-react.cjs.mjs",
|
||||
"default": "./dist/emotion-react.cjs.js"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
|
||||
browser: "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
|
||||
},
|
||||
"./_isolated-hnrs": {
|
||||
module: {
|
||||
worker: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
|
||||
browser: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
|
||||
},
|
||||
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
|
||||
browser: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
},
|
||||
types: "types/index.d.ts",
|
||||
files: [
|
||||
"src",
|
||||
"dist",
|
||||
"jsx-runtime",
|
||||
"jsx-dev-runtime",
|
||||
"_isolated-hnrs",
|
||||
"types/*.d.ts",
|
||||
"macro.*"
|
||||
],
|
||||
sideEffects: false,
|
||||
author: "Emotion Contributors",
|
||||
license: "MIT",
|
||||
scripts: {
|
||||
"test:typescript": "dtslint types"
|
||||
},
|
||||
dependencies: {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@emotion/babel-plugin": "^11.11.0",
|
||||
"@emotion/cache": "^11.11.0",
|
||||
"@emotion/serialize": "^1.1.3",
|
||||
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
|
||||
"@emotion/utils": "^1.2.1",
|
||||
"@emotion/weak-memoize": "^0.3.1",
|
||||
"hoist-non-react-statics": "^3.3.1"
|
||||
},
|
||||
peerDependencies: {
|
||||
react: ">=16.8.0"
|
||||
},
|
||||
peerDependenciesMeta: {
|
||||
"@types/react": {
|
||||
optional: true
|
||||
}
|
||||
},
|
||||
devDependencies: {
|
||||
"@definitelytyped/dtslint": "0.0.112",
|
||||
"@emotion/css": "11.11.2",
|
||||
"@emotion/css-prettifier": "1.1.3",
|
||||
"@emotion/server": "11.11.0",
|
||||
"@emotion/styled": "11.11.0",
|
||||
"html-tag-names": "^1.1.2",
|
||||
react: "16.14.0",
|
||||
"svg-tag-names": "^1.1.1",
|
||||
typescript: "^4.5.5"
|
||||
},
|
||||
repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
|
||||
publishConfig: {
|
||||
access: "public"
|
||||
},
|
||||
"umd:main": "dist/emotion-react.umd.min.js",
|
||||
preconstruct: {
|
||||
entrypoints: [
|
||||
"./index.js",
|
||||
"./jsx-runtime.js",
|
||||
"./jsx-dev-runtime.js",
|
||||
"./_isolated-hnrs.js"
|
||||
],
|
||||
umdName: "emotionReact",
|
||||
exports: {
|
||||
envConditions: [
|
||||
"browser",
|
||||
"worker"
|
||||
],
|
||||
extra: {
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var jsx = function jsx(type, props) {
|
||||
var args = arguments;
|
||||
|
||||
if (props == null || !hasOwn.call(props, 'css')) {
|
||||
// $FlowFixMe
|
||||
return React.createElement.apply(undefined, args);
|
||||
}
|
||||
|
||||
var argsLength = args.length;
|
||||
var createElementArgArray = new Array(argsLength);
|
||||
createElementArgArray[0] = Emotion;
|
||||
createElementArgArray[1] = createEmotionProps(type, props);
|
||||
|
||||
for (var i = 2; i < argsLength; i++) {
|
||||
createElementArgArray[i] = args[i];
|
||||
} // $FlowFixMe
|
||||
|
||||
|
||||
return React.createElement.apply(null, createElementArgArray);
|
||||
};
|
||||
|
||||
var 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
|
||||
|
||||
var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
if (process.env.NODE_ENV !== 'production' && !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
|
||||
// $FlowFixMe 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;
|
||||
}
|
||||
|
||||
var styles = props.styles;
|
||||
var serialized = serializeStyles([styles], undefined, React.useContext(ThemeContext));
|
||||
|
||||
if (!isBrowser$1) {
|
||||
var _ref;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var serializedStyles = serialized.styles;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
serializedStyles += next.styles;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
var shouldCache = cache.compat === true;
|
||||
var rules = cache.insert("", {
|
||||
name: serializedNames,
|
||||
styles: serializedStyles
|
||||
}, cache.sheet, shouldCache);
|
||||
|
||||
if (shouldCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement("style", (_ref = {}, _ref["data-emotion"] = cache.key + "-global " + serializedNames, _ref.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref.nonce = cache.sheet.nonce, _ref));
|
||||
} // 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
|
||||
|
||||
|
||||
var sheetRef = React.useRef();
|
||||
useInsertionEffectWithLayoutFallback(function () {
|
||||
var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
|
||||
|
||||
var sheet = new cache.sheet.constructor({
|
||||
key: key,
|
||||
nonce: cache.sheet.nonce,
|
||||
container: cache.sheet.container,
|
||||
speedy: cache.sheet.isSpeedy
|
||||
});
|
||||
var rehydrating = false; // $FlowFixMe
|
||||
|
||||
var node = 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 function () {
|
||||
sheet.flush();
|
||||
};
|
||||
}, [cache]);
|
||||
useInsertionEffectWithLayoutFallback(function () {
|
||||
var sheetRefCurrent = sheetRef.current;
|
||||
var sheet = sheetRefCurrent[0],
|
||||
rehydrating = sheetRefCurrent[1];
|
||||
|
||||
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
|
||||
var element = sheet.tags[sheet.tags.length - 1].nextElementSibling;
|
||||
sheet.before = element;
|
||||
sheet.flush();
|
||||
}
|
||||
|
||||
cache.insert("", serialized, sheet, false);
|
||||
}, [cache, serialized.name]);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Global.displayName = 'EmotionGlobal';
|
||||
}
|
||||
|
||||
function css() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return serializeStyles(args);
|
||||
}
|
||||
|
||||
var keyframes = function keyframes() {
|
||||
var insertable = css.apply(void 0, arguments);
|
||||
var name = "animation-" + insertable.name; // $FlowFixMe
|
||||
|
||||
return {
|
||||
name: name,
|
||||
styles: "@keyframes " + name + "{" + insertable.styles + "}",
|
||||
anim: 1,
|
||||
toString: function toString() {
|
||||
return "_EMO_" + this.name + "_" + this.styles + "_EMO_";
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var classnames = function classnames(args) {
|
||||
var len = args.length;
|
||||
var i = 0;
|
||||
var cls = '';
|
||||
|
||||
for (; i < len; i++) {
|
||||
var arg = args[i];
|
||||
if (arg == null) continue;
|
||||
var toAdd = void 0;
|
||||
|
||||
switch (typeof arg) {
|
||||
case 'boolean':
|
||||
break;
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (Array.isArray(arg)) {
|
||||
toAdd = classnames(arg);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && 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 (var 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, css, className) {
|
||||
var registeredStyles = [];
|
||||
var rawClassName = getRegisteredStyles(registered, registeredStyles, className);
|
||||
|
||||
if (registeredStyles.length < 2) {
|
||||
return className;
|
||||
}
|
||||
|
||||
return rawClassName + css(registeredStyles);
|
||||
}
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serializedArr = _ref.serializedArr;
|
||||
var rules = useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
var rules = '';
|
||||
|
||||
for (var i = 0; i < serializedArr.length; i++) {
|
||||
var res = insertStyles(cache, serializedArr[i], false);
|
||||
|
||||
if (!isBrowser$1 && res !== undefined) {
|
||||
rules += res;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isBrowser$1) {
|
||||
return rules;
|
||||
}
|
||||
});
|
||||
|
||||
if (!isBrowser$1 && rules.length !== 0) {
|
||||
var _ref2;
|
||||
|
||||
return /*#__PURE__*/React.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedArr.map(function (serialized) {
|
||||
return serialized.name;
|
||||
}).join(' '), _ref2.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
var hasRendered = false;
|
||||
var serializedArr = [];
|
||||
|
||||
var css = function css() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error('css can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var 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;
|
||||
};
|
||||
|
||||
var cx = function cx() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error('cx can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return merge(cache.registered, css, classnames(args));
|
||||
};
|
||||
|
||||
var content = {
|
||||
css: css,
|
||||
cx: cx,
|
||||
theme: React.useContext(ThemeContext)
|
||||
};
|
||||
var ele = props.children(content);
|
||||
hasRendered = true;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serializedArr: serializedArr
|
||||
}), ele);
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ClassNames.displayName = 'EmotionClassNames';
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var isBrowser = typeof document !== 'undefined'; // #1727, #2905 for some reason Jest and Vitest evaluate modules twice if some consuming module gets mocked
|
||||
|
||||
var 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
|
||||
var globalContext = // $FlowIgnore
|
||||
typeof globalThis !== 'undefined' ? globalThis // eslint-disable-line no-undef
|
||||
: isBrowser ? window : global;
|
||||
var 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;
|
||||
}
|
||||
}
|
||||
|
||||
export { ClassNames, Global, jsx as createElement, css, jsx, keyframes };
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).emotionReact={},e.React)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(t);var a=function(){function e(e){var t=this;this._insertTag=function(e){var r;r=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,r),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{r.insertRule(e,r.cssRules.length)}catch(e){}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode&&e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0},e}(),o="-ms-",c="-moz-",s="-webkit-",i="comm",u="rule",f="decl",l="@keyframes",p=Math.abs,d=String.fromCharCode,h=Object.assign;function y(e){return e.trim()}function m(e,t,r){return e.replace(t,r)}function v(e,t){return e.indexOf(t)}function g(e,t){return 0|e.charCodeAt(t)}function b(e,t,r){return e.slice(t,r)}function w(e){return e.length}function x(e){return e.length}function $(e,t){return t.push(e),e}var C=1,k=1,S=0,E=0,O=0,_="";function A(e,t,r,n,a,o,c){return{value:e,root:t,parent:r,type:n,props:a,children:o,line:C,column:k,length:c,return:""}}function P(e,t){return h(A("",null,null,"",null,null,0),e,{length:-e.length},t)}function j(){return O=E>0?g(_,--E):0,k--,10===O&&(k=1,C--),O}function T(){return O=E<S?g(_,E++):0,k++,10===O&&(k=1,C++),O}function M(){return g(_,E)}function N(){return E}function R(e,t){return b(_,e,t)}function z(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function F(e){return C=k=1,S=w(_=e),E=0,[]}function D(e){return _="",e}function I(e){return y(R(E-1,W(91===e?e+2:40===e?e+1:e)))}function G(e){for(;(O=M())&&O<33;)T();return z(e)>2||z(O)>3?"":" "}function L(e,t){for(;--t&&T()&&!(O<48||O>102||O>57&&O<65||O>70&&O<97););return R(e,N()+(t<6&&32==M()&&32==T()))}function W(e){for(;T();)switch(O){case e:return E;case 34:case 39:34!==e&&39!==e&&W(O);break;case 40:41===e&&W(e);break;case 92:T()}return E}function q(e,t){for(;T()&&e+O!==57&&(e+O!==84||47!==M()););return"/*"+R(t,E-1)+"*"+d(47===e?e:T())}function H(e){for(;!z(M());)T();return R(e,E)}function B(e){return D(U("",null,null,null,[""],e=F(e),0,[0],e))}function U(e,t,r,n,a,o,c,s,i){for(var u=0,f=0,l=c,p=0,h=0,y=0,b=1,x=1,C=1,k=0,S="",E=a,O=o,_=n,A=S;x;)switch(y=k,k=T()){case 40:if(108!=y&&58==g(A,l-1)){-1!=v(A+=m(I(k),"&","&\f"),"&\f")&&(C=-1);break}case 34:case 39:case 91:A+=I(k);break;case 9:case 10:case 13:case 32:A+=G(y);break;case 92:A+=L(N()-1,7);continue;case 47:switch(M()){case 42:case 47:$(Y(q(T(),N()),t,r),i);break;default:A+="/"}break;case 123*b:s[u++]=w(A)*C;case 125*b:case 59:case 0:switch(k){case 0:case 125:x=0;case 59+f:-1==C&&(A=m(A,/\f/g,"")),h>0&&w(A)-l&&$(h>32?Z(A+";",n,r,l-1):Z(m(A," ","")+";",n,r,l-2),i);break;case 59:A+=";";default:if($(_=V(A,t,r,u,f,a,s,S,E=[],O=[],l),o),123===k)if(0===f)U(A,t,_,_,E,o,l,s,O);else switch(99===p&&110===g(A,3)?100:p){case 100:case 108:case 109:case 115:U(e,_,_,n&&$(V(e,_,_,0,0,a,s,S,a,E=[],l),O),a,O,l,s,n?E:O);break;default:U(A,_,_,_,[""],O,0,s,O)}}u=f=h=0,b=C=1,S=A="",l=c;break;case 58:l=1+w(A),h=y;default:if(b<1)if(123==k)--b;else if(125==k&&0==b++&&125==j())continue;switch(A+=d(k),k*b){case 38:C=f>0?1:(A+="\f",-1);break;case 44:s[u++]=(w(A)-1)*C,C=1;break;case 64:45===M()&&(A+=I(T())),p=M(),f=l=w(S=A+=H(N())),k++;break;case 45:45===y&&2==w(A)&&(b=0)}}return o}function V(e,t,r,n,a,o,c,s,i,f,l){for(var d=a-1,h=0===a?o:[""],v=x(h),g=0,w=0,$=0;g<n;++g)for(var C=0,k=b(e,d+1,d=p(w=c[g])),S=e;C<v;++C)(S=y(w>0?h[C]+" "+k:m(k,/&\f/g,h[C])))&&(i[$++]=Line truncated
|
||||
//# sourceMappingURL=emotion-react.umd.min.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react.umd.min.js","sources":["../../sheet/src/index.js","../../../node_modules/stylis/src/Enum.js","../../../node_modules/stylis/src/Utility.js","../../../node_modules/stylis/src/Tokenizer.js","../../../node_modules/stylis/src/Parser.js","../../../node_modules/stylis/src/Serializer.js","../../weak-memoize/src/index.js","../../memoize/src/index.js","../../cache/src/stylis-plugins.js","../../cache/src/prefixer.js","../../cache/src/index.js","../../../node_modules/stylis/src/Middleware.js","../src/utils.js","../src/context.js","../../../node_modules/@babel/runtime/helpers/esm/extends.js","../../../node_modules/react-is/cjs/react-is.production.min.js","../../../node_modules/react-is/index.js","../../../node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js","../src/theming.js","../../utils/src/index.js","../../unitless/src/index.js","../../serialize/src/index.js","../../hash/src/index.js","../../use-insertion-effect-with-fallbacks/src/index.js","../src/emotion-element.js","../src/jsx.js","../src/global.js","../src/css.js","../src/keyframes.js","../src/class-names.js","../src/_isolated-hnrs.js"],"sourcesContent":["// @flow\n/*\n\nBased off glamor's StyleSheet, thanks Sunil ❤️\n\nhigh performance StyleSheet for css-in-js systems\n\n- uses multiple style tags behind the scenes for millions of rules\n- uses `insertRule` for appending in production for *much* faster performance\n\n// usage\n\nimport { StyleSheet } from '@emotion/sheet'\n\nlet styleSheet = new StyleSheet({ key: '', container: document.head })\n\nstyleSheet.insert('#box { border: 1px solid red; }')\n- appends a css rule into the stylesheet\n\nstyleSheet.flush()\n- empties the stylesheet of all its contents\n\n*/\n\n// $FlowFixMe\nfunction sheetForTag(tag: HTMLStyleElement): CSSStyleSheet {\n if (tag.sheet) {\n // $FlowFixMe\n return tag.sheet\n }\n\n // this weirdness brought to you by firefox\n /* istanbul ignore next */\n for (let i = 0; i < document.styleSheets.length; i++) {\n if (document.styleSheets[i].ownerNode === tag) {\n // $FlowFixMe\n return document.styleSheets[i]\n }\n }\n}\n\nexport type Options = {\n nonce?: string,\n key: string,\n container: Node,\n speedy?: boolean,\n prepend?: boolean,\n insertionPoint?: HTMLElement\n}\n\nfunction createStyleElement(options: {\n key: string,\n nonce: string | void\n}): HTMLStyleElement {\n let tag = document.createElement('style')\n tag.setAttribute('data-emotion', options.key)\n if (options.nonce !== undefined) {\n tag.setAttribute('nonce', options.nonce)\n }\n tag.appendChild(document.createTextNode(''))\n tag.setAttribute('data-s', '')\n return tag\n}\n\nexport class StyleSheet {\n isSpeedy: boolean\n ctr: number\n tags: HTMLStyleElement[]\n // Using Node instead of HTMLElement since container may be a ShadowRoot\n container: Node\n key: string\n nonce: string | void\n prepend: boolean | void\n before: Element | null\n insertionPoint: HTMLElement | void\n constructor(options: Options) {\n this.isSpeedy =\n options.speedy === undefined\n ? process.env.NODE_ENV === 'production'\n : options.speedy\n this.tags = []\n this.ctr = 0\n this.nonce = options.nonce\n // key is the value of the data-emotion attribute, it's used to identify different sheets\n this.key = options.key\n this.container = options.container\n this.prepend = options.prepend\n this.insertionPoint = options.insertionPoint\n this.before = null\n }\n\n _insertTag = (tag: HTMLStyleElement) => {\n let before\n if (this.tags.length === 0) {\n if (this.insertionPoint) {\n before = this.insertionPoint.nextSibling\n } else if (this.prepend) {\n before = this.container.firstChild\n } else {\n before = this.before\n }\n } else {\n before = this.tags[this.tags.length - 1].nextSibling\n }\n this.container.insertBefore(tag, before)\n this.tags.push(tag)\n }\n\n hydrate(nodes: HTMLStyleElement[]) {\n nodes.forEach(this._insertTag)\n }\n\n insert(rule: string) {\n // the max length is how many rules we have per style tag, it's 65000 in speedy mode\n // it's 1 in dev because we insert source maps that map a single rule to a location\n // and you can only have one source map per style tag\n if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {\n this._insertTag(createStyleElement(this))\n }\n const tag = this.tags[this.tags.length - 1]\n\n if (process.env.NODE_ENV !== 'production') {\n const isImportRule =\n rule.charCodeAt(0) === 64 && rule.charCodeAt(1) === 105\n\n if (isImportRule && (this: any)._alreadyInsertedOrderInsensitiveRule) {\n // this would only cause problem in speedy mode\n // but we don't want enabling speedy to affect the observable behavior\n // so we report this error at all times\n console.error(\n `You're attempting to insert Line truncated
|
||||
+461
@@ -0,0 +1,461 @@
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps, w as withEmotionCache, T as ThemeContext, i as isBrowser$1 } from './emotion-element-3ac3b1d0.worker.esm.js';
|
||||
export { C as CacheProvider, T as ThemeContext, a as ThemeProvider, _ as __unsafe_useEmotionCache, u as useTheme, w as withEmotionCache, b as withTheme } from './emotion-element-3ac3b1d0.worker.esm.js';
|
||||
import * as React from 'react';
|
||||
import { insertStyles, registerStyles, getRegisteredStyles } from '@emotion/utils';
|
||||
import { useInsertionEffectWithLayoutFallback, useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
|
||||
var pkg = {
|
||||
name: "@emotion/react",
|
||||
version: "11.11.4",
|
||||
main: "dist/emotion-react.cjs.js",
|
||||
module: "dist/emotion-react.esm.js",
|
||||
browser: {
|
||||
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
|
||||
},
|
||||
exports: {
|
||||
".": {
|
||||
module: {
|
||||
worker: "./dist/emotion-react.worker.esm.js",
|
||||
browser: "./dist/emotion-react.browser.esm.js",
|
||||
"default": "./dist/emotion-react.esm.js"
|
||||
},
|
||||
"import": "./dist/emotion-react.cjs.mjs",
|
||||
"default": "./dist/emotion-react.cjs.js"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
|
||||
browser: "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
|
||||
},
|
||||
"./_isolated-hnrs": {
|
||||
module: {
|
||||
worker: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
|
||||
browser: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
|
||||
},
|
||||
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
|
||||
browser: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
},
|
||||
types: "types/index.d.ts",
|
||||
files: [
|
||||
"src",
|
||||
"dist",
|
||||
"jsx-runtime",
|
||||
"jsx-dev-runtime",
|
||||
"_isolated-hnrs",
|
||||
"types/*.d.ts",
|
||||
"macro.*"
|
||||
],
|
||||
sideEffects: false,
|
||||
author: "Emotion Contributors",
|
||||
license: "MIT",
|
||||
scripts: {
|
||||
"test:typescript": "dtslint types"
|
||||
},
|
||||
dependencies: {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@emotion/babel-plugin": "^11.11.0",
|
||||
"@emotion/cache": "^11.11.0",
|
||||
"@emotion/serialize": "^1.1.3",
|
||||
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
|
||||
"@emotion/utils": "^1.2.1",
|
||||
"@emotion/weak-memoize": "^0.3.1",
|
||||
"hoist-non-react-statics": "^3.3.1"
|
||||
},
|
||||
peerDependencies: {
|
||||
react: ">=16.8.0"
|
||||
},
|
||||
peerDependenciesMeta: {
|
||||
"@types/react": {
|
||||
optional: true
|
||||
}
|
||||
},
|
||||
devDependencies: {
|
||||
"@definitelytyped/dtslint": "0.0.112",
|
||||
"@emotion/css": "11.11.2",
|
||||
"@emotion/css-prettifier": "1.1.3",
|
||||
"@emotion/server": "11.11.0",
|
||||
"@emotion/styled": "11.11.0",
|
||||
"html-tag-names": "^1.1.2",
|
||||
react: "16.14.0",
|
||||
"svg-tag-names": "^1.1.1",
|
||||
typescript: "^4.5.5"
|
||||
},
|
||||
repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
|
||||
publishConfig: {
|
||||
access: "public"
|
||||
},
|
||||
"umd:main": "dist/emotion-react.umd.min.js",
|
||||
preconstruct: {
|
||||
entrypoints: [
|
||||
"./index.js",
|
||||
"./jsx-runtime.js",
|
||||
"./jsx-dev-runtime.js",
|
||||
"./_isolated-hnrs.js"
|
||||
],
|
||||
umdName: "emotionReact",
|
||||
exports: {
|
||||
envConditions: [
|
||||
"browser",
|
||||
"worker"
|
||||
],
|
||||
extra: {
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var jsx = function jsx(type, props) {
|
||||
var args = arguments;
|
||||
|
||||
if (props == null || !hasOwn.call(props, 'css')) {
|
||||
// $FlowFixMe
|
||||
return React.createElement.apply(undefined, args);
|
||||
}
|
||||
|
||||
var argsLength = args.length;
|
||||
var createElementArgArray = new Array(argsLength);
|
||||
createElementArgArray[0] = Emotion;
|
||||
createElementArgArray[1] = createEmotionProps(type, props);
|
||||
|
||||
for (var i = 2; i < argsLength; i++) {
|
||||
createElementArgArray[i] = args[i];
|
||||
} // $FlowFixMe
|
||||
|
||||
|
||||
return React.createElement.apply(null, createElementArgArray);
|
||||
};
|
||||
|
||||
var 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
|
||||
|
||||
var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
if (process.env.NODE_ENV !== 'production' && !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
|
||||
// $FlowFixMe 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;
|
||||
}
|
||||
|
||||
var styles = props.styles;
|
||||
var serialized = serializeStyles([styles], undefined, React.useContext(ThemeContext));
|
||||
|
||||
if (!isBrowser$1) {
|
||||
var _ref;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var serializedStyles = serialized.styles;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
serializedStyles += next.styles;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
var shouldCache = cache.compat === true;
|
||||
var rules = cache.insert("", {
|
||||
name: serializedNames,
|
||||
styles: serializedStyles
|
||||
}, cache.sheet, shouldCache);
|
||||
|
||||
if (shouldCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement("style", (_ref = {}, _ref["data-emotion"] = cache.key + "-global " + serializedNames, _ref.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref.nonce = cache.sheet.nonce, _ref));
|
||||
} // 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
|
||||
|
||||
|
||||
var sheetRef = React.useRef();
|
||||
useInsertionEffectWithLayoutFallback(function () {
|
||||
var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
|
||||
|
||||
var sheet = new cache.sheet.constructor({
|
||||
key: key,
|
||||
nonce: cache.sheet.nonce,
|
||||
container: cache.sheet.container,
|
||||
speedy: cache.sheet.isSpeedy
|
||||
});
|
||||
var rehydrating = false; // $FlowFixMe
|
||||
|
||||
var node = 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 function () {
|
||||
sheet.flush();
|
||||
};
|
||||
}, [cache]);
|
||||
useInsertionEffectWithLayoutFallback(function () {
|
||||
var sheetRefCurrent = sheetRef.current;
|
||||
var sheet = sheetRefCurrent[0],
|
||||
rehydrating = sheetRefCurrent[1];
|
||||
|
||||
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
|
||||
var element = sheet.tags[sheet.tags.length - 1].nextElementSibling;
|
||||
sheet.before = element;
|
||||
sheet.flush();
|
||||
}
|
||||
|
||||
cache.insert("", serialized, sheet, false);
|
||||
}, [cache, serialized.name]);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Global.displayName = 'EmotionGlobal';
|
||||
}
|
||||
|
||||
function css() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return serializeStyles(args);
|
||||
}
|
||||
|
||||
var keyframes = function keyframes() {
|
||||
var insertable = css.apply(void 0, arguments);
|
||||
var name = "animation-" + insertable.name; // $FlowFixMe
|
||||
|
||||
return {
|
||||
name: name,
|
||||
styles: "@keyframes " + name + "{" + insertable.styles + "}",
|
||||
anim: 1,
|
||||
toString: function toString() {
|
||||
return "_EMO_" + this.name + "_" + this.styles + "_EMO_";
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var classnames = function classnames(args) {
|
||||
var len = args.length;
|
||||
var i = 0;
|
||||
var cls = '';
|
||||
|
||||
for (; i < len; i++) {
|
||||
var arg = args[i];
|
||||
if (arg == null) continue;
|
||||
var toAdd = void 0;
|
||||
|
||||
switch (typeof arg) {
|
||||
case 'boolean':
|
||||
break;
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (Array.isArray(arg)) {
|
||||
toAdd = classnames(arg);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && 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 (var 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, css, className) {
|
||||
var registeredStyles = [];
|
||||
var rawClassName = getRegisteredStyles(registered, registeredStyles, className);
|
||||
|
||||
if (registeredStyles.length < 2) {
|
||||
return className;
|
||||
}
|
||||
|
||||
return rawClassName + css(registeredStyles);
|
||||
}
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serializedArr = _ref.serializedArr;
|
||||
var rules = useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
var rules = '';
|
||||
|
||||
for (var i = 0; i < serializedArr.length; i++) {
|
||||
var res = insertStyles(cache, serializedArr[i], false);
|
||||
|
||||
if (res !== undefined) {
|
||||
rules += res;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
return rules;
|
||||
}
|
||||
});
|
||||
|
||||
if (rules.length !== 0) {
|
||||
var _ref2;
|
||||
|
||||
return /*#__PURE__*/React.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedArr.map(function (serialized) {
|
||||
return serialized.name;
|
||||
}).join(' '), _ref2.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
var hasRendered = false;
|
||||
var serializedArr = [];
|
||||
|
||||
var css = function css() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error('css can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var 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;
|
||||
};
|
||||
|
||||
var cx = function cx() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error('cx can only be used during render');
|
||||
}
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return merge(cache.registered, css, classnames(args));
|
||||
};
|
||||
|
||||
var content = {
|
||||
css: css,
|
||||
cx: cx,
|
||||
theme: React.useContext(ThemeContext)
|
||||
};
|
||||
var ele = props.children(content);
|
||||
hasRendered = true;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serializedArr: serializedArr
|
||||
}), ele);
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ClassNames.displayName = 'EmotionClassNames';
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var isBrowser = "undefined" !== 'undefined'; // #1727, #2905 for some reason Jest and Vitest evaluate modules twice if some consuming module gets mocked
|
||||
|
||||
var 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
|
||||
var globalContext = // $FlowIgnore
|
||||
typeof globalThis !== 'undefined' ? globalThis // eslint-disable-line no-undef
|
||||
: isBrowser ? window : global;
|
||||
var 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;
|
||||
}
|
||||
}
|
||||
|
||||
export { ClassNames, Global, jsx as createElement, css, jsx, keyframes };
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import * as ReactJSXRuntimeDev from 'react/jsx-dev-runtime';
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps } from '../../dist/emotion-element-43c6fea0.browser.esm.js';
|
||||
import 'react';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
import '@emotion/utils';
|
||||
import '@emotion/serialize';
|
||||
import '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var Fragment = ReactJSXRuntimeDev.Fragment;
|
||||
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);
|
||||
}
|
||||
|
||||
export { Fragment, jsxDEV };
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export * from "../../dist/declarations/src/jsx-dev-runtime.js";
|
||||
//# sourceMappingURL=emotion-react-jsx-dev-runtime.cjs.d.mts.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-jsx-dev-runtime.cjs.d.mts","sourceRoot":"","sources":["../../dist/declarations/src/jsx-dev-runtime.d.ts"],"names":[],"mappings":"AAAA"}
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export * from "../../dist/declarations/src/jsx-dev-runtime";
|
||||
//# sourceMappingURL=emotion-react-jsx-dev-runtime.cjs.d.ts.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-jsx-dev-runtime.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/jsx-dev-runtime.d.ts"],"names":[],"mappings":"AAAA"}
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var ReactJSXRuntimeDev = require('react/jsx-dev-runtime');
|
||||
var emotionElement = require('../../dist/emotion-element-f93e57b0.cjs.dev.js');
|
||||
require('react');
|
||||
require('@emotion/cache');
|
||||
require('@babel/runtime/helpers/extends');
|
||||
require('@emotion/weak-memoize');
|
||||
require('../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.dev.js');
|
||||
require('hoist-non-react-statics');
|
||||
require('@emotion/utils');
|
||||
require('@emotion/serialize');
|
||||
require('@emotion/use-insertion-effect-with-fallbacks');
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var ReactJSXRuntimeDev__namespace = /*#__PURE__*/_interopNamespace(ReactJSXRuntimeDev);
|
||||
|
||||
var Fragment = ReactJSXRuntimeDev__namespace.Fragment;
|
||||
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
||||
if (!emotionElement.hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntimeDev__namespace.jsxDEV(type, props, key, isStaticChildren, source, self);
|
||||
}
|
||||
|
||||
return ReactJSXRuntimeDev__namespace.jsxDEV(emotionElement.Emotion, emotionElement.createEmotionProps(type, props), key, isStaticChildren, source, self);
|
||||
}
|
||||
|
||||
exports.Fragment = Fragment;
|
||||
exports.jsxDEV = jsxDEV;
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
module.exports = require("./emotion-react-jsx-dev-runtime.cjs.prod.js");
|
||||
} else {
|
||||
module.exports = require("./emotion-react-jsx-dev-runtime.cjs.dev.js");
|
||||
}
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
export * from "../../src/jsx-dev-runtime.js";
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
Fragment,
|
||||
jsxDEV
|
||||
} from "./emotion-react-jsx-dev-runtime.cjs.js";
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var ReactJSXRuntimeDev = require('react/jsx-dev-runtime');
|
||||
var emotionElement = require('../../dist/emotion-element-eec0d725.cjs.prod.js');
|
||||
require('react');
|
||||
require('@emotion/cache');
|
||||
require('@babel/runtime/helpers/extends');
|
||||
require('@emotion/weak-memoize');
|
||||
require('../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.prod.js');
|
||||
require('hoist-non-react-statics');
|
||||
require('@emotion/utils');
|
||||
require('@emotion/serialize');
|
||||
require('@emotion/use-insertion-effect-with-fallbacks');
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var ReactJSXRuntimeDev__namespace = /*#__PURE__*/_interopNamespace(ReactJSXRuntimeDev);
|
||||
|
||||
var Fragment = ReactJSXRuntimeDev__namespace.Fragment;
|
||||
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
||||
if (!emotionElement.hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntimeDev__namespace.jsxDEV(type, props, key, isStaticChildren, source, self);
|
||||
}
|
||||
|
||||
return ReactJSXRuntimeDev__namespace.jsxDEV(emotionElement.Emotion, emotionElement.createEmotionProps(type, props), key, isStaticChildren, source, self);
|
||||
}
|
||||
|
||||
exports.Fragment = Fragment;
|
||||
exports.jsxDEV = jsxDEV;
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import * as ReactJSXRuntimeDev from 'react/jsx-dev-runtime';
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps } from '../../dist/emotion-element-c16c303e.esm.js';
|
||||
import 'react';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
import '@emotion/utils';
|
||||
import '@emotion/serialize';
|
||||
import '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var Fragment = ReactJSXRuntimeDev.Fragment;
|
||||
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);
|
||||
}
|
||||
|
||||
export { Fragment, jsxDEV };
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-dev-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-dev-runtime","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).emotionReactJSXDevRuntime={},e.ReactJSXDev,e.React)}(this,(function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=n(t),s=n(r);var c=function(){function e(e){var t=this;this._insertTag=function(e){var r;r=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,r),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{r.insertRule(e,r.cssRules.length)}catch(e){}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode&&e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0},e}(),i="-ms-",o="-moz-",u="-webkit-",l="comm",f="rule",d="decl",h="@keyframes",p=Math.abs,v=String.fromCharCode,g=Object.assign;function m(e){return e.trim()}function y(e,t,r){return e.replace(t,r)}function b(e,t){return e.indexOf(t)}function x(e,t){return 0|e.charCodeAt(t)}function w(e,t,r){return e.slice(t,r)}function k(e){return e.length}function $(e){return e.length}function C(e,t){return t.push(e),e}var A=1,S=1,E=0,O=0,_=0,j="";function N(e,t,r,n,a,s,c){return{value:e,root:t,parent:r,type:n,props:a,children:s,line:A,column:S,length:c,return:""}}function P(e,t){return g(N("",null,null,"",null,null,0),e,{length:-e.length},t)}function R(){return _=O>0?x(j,--O):0,S--,10===_&&(S=1,A--),_}function T(){return _=O<E?x(j,O++):0,S++,10===_&&(S=1,A++),_}function z(){return x(j,O)}function D(){return O}function I(e,t){return w(j,e,t)}function M(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function G(e){return A=S=1,E=k(j=e),O=0,[]}function F(e){return j="",e}function W(e){return m(I(O-1,V(91===e?e+2:40===e?e+1:e)))}function q(e){for(;(_=z())&&_<33;)T();return M(e)>2||M(_)>3?"":" "}function L(e,t){for(;--t&&T()&&!(_<48||_>102||_>57&&_<65||_>70&&_<97););return I(e,D()+(t<6&&32==z()&&32==T()))}function V(e){for(;T();)switch(_){case e:return O;case 34:case 39:34!==e&&39!==e&&V(_);break;case 40:41===e&&V(e);break;case 92:T()}return O}function H(e,t){for(;T()&&e+_!==57&&(e+_!==84||47!==z()););return"/*"+I(t,O-1)+"*"+v(47===e?e:T())}function J(e){for(;!M(z());)T();return I(e,O)}function X(e){return F(B("",null,null,null,[""],e=G(e),0,[0],e))}function B(e,t,r,n,a,s,c,i,o){for(var u=0,l=0,f=c,d=0,h=0,p=0,g=1,m=1,w=1,$=0,A="",S=a,E=s,O=n,_=A;m;)switch(p=$,$=T()){case 40:if(108!=p&&58==x(_,f-1)){-1!=b(_+=y(W($),"&","&\f"),"&\f")&&(w=-1);break}case 34:case 39:case 91:_+=W($);break;case 9:case 10:case 13:case 32:_+=q(p);break;case 92:_+=L(D()-1,7);continue;case 47:switch(z()){case 42:case 47:C(Y(H(T(),D()),t,r),o);break;default:_+="/"}break;case 123*g:i[u++]=k(_)*w;case 125*g:case 59:case 0:switch($){case 0:case 125:m=0;case 59+l:-1==w&&(_=y(_,/\f/g,"")),h>0&&k(_)-f&&C(h>32?Z(_+";",n,r,f-1):Z(y(_," ","")+";",n,r,f-2),o);break;case 59:_+=";";default:if(C(O=U(_,t,r,u,l,a,i,A,S=[],E=[],f),s),123===$)if(0===l)B(_,t,O,O,S,s,f,i,E);else switch(99===d&&110===x(_,3)?100:d){case 100:case 108:case 109:case 115:B(e,O,O,n&&C(U(e,O,O,0,0,a,i,A,a,S=[],f),E),a,E,f,i,n?S:E);break;default:B(_,O,O,O,[""],E,0,i,E)}}u=l=h=0,g=w=1,A=_="",f=c;break;case 58:f=1+k(_),h=p;default:if(g<1)if(123==$)--g;else if(125==$&&0==g++&&125==R())continue;switch(_+=v($),$*g){case 38:w=l>0?1:(_+="\f",-1);break;case 44:i[u++]=(k(_)-1)*w,w=1;break;case 64:45===z()&&(_+=W(T())),d=z(),l=f=k(A=_+=J(D())),$++;break;case 45:45===p&&2==k(_)&&(g=0)}}return s}function U(e,t,r,n,a,s,c,i,o,u,l){for(var d=a-1,h=0===a?s:[""],v=$(h),g=0,b=0,x=0;g<n;++g)foLine truncated
|
||||
//# sourceMappingURL=emotion-react-jsx-dev-runtime.umd.min.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-jsx-dev-runtime.umd.min.js","sources":["../../../sheet/src/index.js","../../../../node_modules/stylis/src/Enum.js","../../../../node_modules/stylis/src/Utility.js","../../../../node_modules/stylis/src/Tokenizer.js","../../../../node_modules/stylis/src/Parser.js","../../../../node_modules/stylis/src/Serializer.js","../../../memoize/src/index.js","../../../cache/src/stylis-plugins.js","../../../cache/src/prefixer.js","../../../cache/src/index.js","../../../../node_modules/stylis/src/Middleware.js","../../src/utils.js","../../src/context.js","../../src/theming.js","../../../utils/src/index.js","../../../unitless/src/index.js","../../../serialize/src/index.js","../../../use-insertion-effect-with-fallbacks/src/index.js","../../src/emotion-element.js","../../../hash/src/index.js","../../src/jsx-dev-runtime.js"],"sourcesContent":["// @flow\n/*\n\nBased off glamor's StyleSheet, thanks Sunil ❤️\n\nhigh performance StyleSheet for css-in-js systems\n\n- uses multiple style tags behind the scenes for millions of rules\n- uses `insertRule` for appending in production for *much* faster performance\n\n// usage\n\nimport { StyleSheet } from '@emotion/sheet'\n\nlet styleSheet = new StyleSheet({ key: '', container: document.head })\n\nstyleSheet.insert('#box { border: 1px solid red; }')\n- appends a css rule into the stylesheet\n\nstyleSheet.flush()\n- empties the stylesheet of all its contents\n\n*/\n\n// $FlowFixMe\nfunction sheetForTag(tag: HTMLStyleElement): CSSStyleSheet {\n if (tag.sheet) {\n // $FlowFixMe\n return tag.sheet\n }\n\n // this weirdness brought to you by firefox\n /* istanbul ignore next */\n for (let i = 0; i < document.styleSheets.length; i++) {\n if (document.styleSheets[i].ownerNode === tag) {\n // $FlowFixMe\n return document.styleSheets[i]\n }\n }\n}\n\nexport type Options = {\n nonce?: string,\n key: string,\n container: Node,\n speedy?: boolean,\n prepend?: boolean,\n insertionPoint?: HTMLElement\n}\n\nfunction createStyleElement(options: {\n key: string,\n nonce: string | void\n}): HTMLStyleElement {\n let tag = document.createElement('style')\n tag.setAttribute('data-emotion', options.key)\n if (options.nonce !== undefined) {\n tag.setAttribute('nonce', options.nonce)\n }\n tag.appendChild(document.createTextNode(''))\n tag.setAttribute('data-s', '')\n return tag\n}\n\nexport class StyleSheet {\n isSpeedy: boolean\n ctr: number\n tags: HTMLStyleElement[]\n // Using Node instead of HTMLElement since container may be a ShadowRoot\n container: Node\n key: string\n nonce: string | void\n prepend: boolean | void\n before: Element | null\n insertionPoint: HTMLElement | void\n constructor(options: Options) {\n this.isSpeedy =\n options.speedy === undefined\n ? process.env.NODE_ENV === 'production'\n : options.speedy\n this.tags = []\n this.ctr = 0\n this.nonce = options.nonce\n // key is the value of the data-emotion attribute, it's used to identify different sheets\n this.key = options.key\n this.container = options.container\n this.prepend = options.prepend\n this.insertionPoint = options.insertionPoint\n this.before = null\n }\n\n _insertTag = (tag: HTMLStyleElement) => {\n let before\n if (this.tags.length === 0) {\n if (this.insertionPoint) {\n before = this.insertionPoint.nextSibling\n } else if (this.prepend) {\n before = this.container.firstChild\n } else {\n before = this.before\n }\n } else {\n before = this.tags[this.tags.length - 1].nextSibling\n }\n this.container.insertBefore(tag, before)\n this.tags.push(tag)\n }\n\n hydrate(nodes: HTMLStyleElement[]) {\n nodes.forEach(this._insertTag)\n }\n\n insert(rule: string) {\n // the max length is how many rules we have per style tag, it's 65000 in speedy mode\n // it's 1 in dev because we insert source maps that map a single rule to a location\n // and you can only have one source map per style tag\n if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {\n this._insertTag(createStyleElement(this))\n }\n const tag = this.tags[this.tags.length - 1]\n\n if (process.env.NODE_ENV !== 'production') {\n const isImportRule =\n rule.charCodeAt(0) === 64 && rule.charCodeAt(1) === 105\n\n if (isImportRule && (this: any)._alreadyInsertedOrderInsensitiveRule) {\n // this would only cause problem in speedy mode\n // but we don't want enabling speedy to affect the observable behavior\n // so we report this error at all times\n console.error(\n `You're attempting to insert the following rule:\\n` +\n rule +\n '\\n\\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules.'\n )\n }\n\n ;(this: any)._alreadyInserteLine truncated
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import * as ReactJSXRuntimeDev from 'react/jsx-dev-runtime';
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps } from '../../dist/emotion-element-3ac3b1d0.worker.esm.js';
|
||||
import 'react';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
import '@emotion/utils';
|
||||
import '@emotion/serialize';
|
||||
import '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var Fragment = ReactJSXRuntimeDev.Fragment;
|
||||
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);
|
||||
}
|
||||
|
||||
export { Fragment, jsxDEV };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"main": "dist/emotion-react-jsx-dev-runtime.cjs.js",
|
||||
"module": "dist/emotion-react-jsx-dev-runtime.esm.js",
|
||||
"umd:main": "dist/emotion-react-jsx-dev-runtime.umd.min.js",
|
||||
"browser": {
|
||||
"./dist/emotion-react-jsx-dev-runtime.esm.js": "./dist/emotion-react-jsx-dev-runtime.browser.esm.js"
|
||||
},
|
||||
"types": "../types/jsx-dev-runtime",
|
||||
"sideEffects": false,
|
||||
"preconstruct": {
|
||||
"umdName": "emotionReactJSXDevRuntime"
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
import * as ReactJSXRuntime from 'react/jsx-runtime';
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps } from '../../dist/emotion-element-43c6fea0.browser.esm.js';
|
||||
import 'react';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
import '@emotion/utils';
|
||||
import '@emotion/serialize';
|
||||
import '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var Fragment = ReactJSXRuntime.Fragment;
|
||||
function jsx(type, props, key) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsx(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsx(Emotion, createEmotionProps(type, props), key);
|
||||
}
|
||||
function jsxs(type, props, key) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsxs(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsxs(Emotion, createEmotionProps(type, props), key);
|
||||
}
|
||||
|
||||
export { Fragment, jsx, jsxs };
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from "../../dist/declarations/src/jsx-runtime.js";
|
||||
//# sourceMappingURL=emotion-react-jsx-runtime.cjs.d.mts.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-jsx-runtime.cjs.d.mts","sourceRoot":"","sources":["../../dist/declarations/src/jsx-runtime.d.ts"],"names":[],"mappings":"AAAA"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from "../../dist/declarations/src/jsx-runtime";
|
||||
//# sourceMappingURL=emotion-react-jsx-runtime.cjs.d.ts.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-jsx-runtime.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/jsx-runtime.d.ts"],"names":[],"mappings":"AAAA"}
|
||||
Generated
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var ReactJSXRuntime = require('react/jsx-runtime');
|
||||
var emotionElement = require('../../dist/emotion-element-f93e57b0.cjs.dev.js');
|
||||
require('react');
|
||||
require('@emotion/cache');
|
||||
require('@babel/runtime/helpers/extends');
|
||||
require('@emotion/weak-memoize');
|
||||
require('../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.dev.js');
|
||||
require('hoist-non-react-statics');
|
||||
require('@emotion/utils');
|
||||
require('@emotion/serialize');
|
||||
require('@emotion/use-insertion-effect-with-fallbacks');
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var ReactJSXRuntime__namespace = /*#__PURE__*/_interopNamespace(ReactJSXRuntime);
|
||||
|
||||
var Fragment = ReactJSXRuntime__namespace.Fragment;
|
||||
function jsx(type, props, key) {
|
||||
if (!emotionElement.hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime__namespace.jsx(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime__namespace.jsx(emotionElement.Emotion, emotionElement.createEmotionProps(type, props), key);
|
||||
}
|
||||
function jsxs(type, props, key) {
|
||||
if (!emotionElement.hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime__namespace.jsxs(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime__namespace.jsxs(emotionElement.Emotion, emotionElement.createEmotionProps(type, props), key);
|
||||
}
|
||||
|
||||
exports.Fragment = Fragment;
|
||||
exports.jsx = jsx;
|
||||
exports.jsxs = jsxs;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
module.exports = require("./emotion-react-jsx-runtime.cjs.prod.js");
|
||||
} else {
|
||||
module.exports = require("./emotion-react-jsx-runtime.cjs.dev.js");
|
||||
}
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
export * from "../../src/jsx-runtime.js";
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export {
|
||||
Fragment,
|
||||
jsx,
|
||||
jsxs
|
||||
} from "./emotion-react-jsx-runtime.cjs.js";
|
||||
Generated
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var ReactJSXRuntime = require('react/jsx-runtime');
|
||||
var emotionElement = require('../../dist/emotion-element-eec0d725.cjs.prod.js');
|
||||
require('react');
|
||||
require('@emotion/cache');
|
||||
require('@babel/runtime/helpers/extends');
|
||||
require('@emotion/weak-memoize');
|
||||
require('../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.prod.js');
|
||||
require('hoist-non-react-statics');
|
||||
require('@emotion/utils');
|
||||
require('@emotion/serialize');
|
||||
require('@emotion/use-insertion-effect-with-fallbacks');
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var ReactJSXRuntime__namespace = /*#__PURE__*/_interopNamespace(ReactJSXRuntime);
|
||||
|
||||
var Fragment = ReactJSXRuntime__namespace.Fragment;
|
||||
function jsx(type, props, key) {
|
||||
if (!emotionElement.hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime__namespace.jsx(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime__namespace.jsx(emotionElement.Emotion, emotionElement.createEmotionProps(type, props), key);
|
||||
}
|
||||
function jsxs(type, props, key) {
|
||||
if (!emotionElement.hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime__namespace.jsxs(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime__namespace.jsxs(emotionElement.Emotion, emotionElement.createEmotionProps(type, props), key);
|
||||
}
|
||||
|
||||
exports.Fragment = Fragment;
|
||||
exports.jsx = jsx;
|
||||
exports.jsxs = jsxs;
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
import * as ReactJSXRuntime from 'react/jsx-runtime';
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps } from '../../dist/emotion-element-c16c303e.esm.js';
|
||||
import 'react';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
import '@emotion/utils';
|
||||
import '@emotion/serialize';
|
||||
import '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var Fragment = ReactJSXRuntime.Fragment;
|
||||
function jsx(type, props, key) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsx(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsx(Emotion, createEmotionProps(type, props), key);
|
||||
}
|
||||
function jsxs(type, props, key) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsxs(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsxs(Emotion, createEmotionProps(type, props), key);
|
||||
}
|
||||
|
||||
export { Fragment, jsx, jsxs };
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).emotionReactJSXRuntime={},e.ReactJSX,e.React)}(this,(function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=n(t),s=n(r);var c=function(){function e(e){var t=this;this._insertTag=function(e){var r;r=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,r),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{r.insertRule(e,r.cssRules.length)}catch(e){}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode&&e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0},e}(),i="-ms-",o="-moz-",u="-webkit-",l="comm",f="rule",d="decl",h="@keyframes",p=Math.abs,v=String.fromCharCode,g=Object.assign;function m(e){return e.trim()}function y(e,t,r){return e.replace(t,r)}function b(e,t){return e.indexOf(t)}function x(e,t){return 0|e.charCodeAt(t)}function w(e,t,r){return e.slice(t,r)}function k(e){return e.length}function $(e){return e.length}function C(e,t){return t.push(e),e}var A=1,S=1,O=0,_=0,j=0,E="";function N(e,t,r,n,a,s,c){return{value:e,root:t,parent:r,type:n,props:a,children:s,line:A,column:S,length:c,return:""}}function P(e,t){return g(N("",null,null,"",null,null,0),e,{length:-e.length},t)}function R(){return j=_>0?x(E,--_):0,S--,10===j&&(S=1,A--),j}function T(){return j=_<O?x(E,_++):0,S++,10===j&&(S=1,A++),j}function z(){return x(E,_)}function I(){return _}function M(e,t){return w(E,e,t)}function G(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function F(e){return A=S=1,O=k(E=e),_=0,[]}function W(e){return E="",e}function q(e){return m(M(_-1,H(91===e?e+2:40===e?e+1:e)))}function D(e){for(;(j=z())&&j<33;)T();return G(e)>2||G(j)>3?"":" "}function L(e,t){for(;--t&&T()&&!(j<48||j>102||j>57&&j<65||j>70&&j<97););return M(e,I()+(t<6&&32==z()&&32==T()))}function H(e){for(;T();)switch(j){case e:return _;case 34:case 39:34!==e&&39!==e&&H(j);break;case 40:41===e&&H(e);break;case 92:T()}return _}function J(e,t){for(;T()&&e+j!==57&&(e+j!==84||47!==z()););return"/*"+M(t,_-1)+"*"+v(47===e?e:T())}function X(e){for(;!G(z());)T();return M(e,_)}function B(e){return W(U("",null,null,null,[""],e=F(e),0,[0],e))}function U(e,t,r,n,a,s,c,i,o){for(var u=0,l=0,f=c,d=0,h=0,p=0,g=1,m=1,w=1,$=0,A="",S=a,O=s,_=n,j=A;m;)switch(p=$,$=T()){case 40:if(108!=p&&58==x(j,f-1)){-1!=b(j+=y(q($),"&","&\f"),"&\f")&&(w=-1);break}case 34:case 39:case 91:j+=q($);break;case 9:case 10:case 13:case 32:j+=D(p);break;case 92:j+=L(I()-1,7);continue;case 47:switch(z()){case 42:case 47:C(Z(J(T(),I()),t,r),o);break;default:j+="/"}break;case 123*g:i[u++]=k(j)*w;case 125*g:case 59:case 0:switch($){case 0:case 125:m=0;case 59+l:-1==w&&(j=y(j,/\f/g,"")),h>0&&k(j)-f&&C(h>32?K(j+";",n,r,f-1):K(y(j," ","")+";",n,r,f-2),o);break;case 59:j+=";";default:if(C(_=Y(j,t,r,u,l,a,i,A,S=[],O=[],f),s),123===$)if(0===l)U(j,t,_,_,S,s,f,i,O);else switch(99===d&&110===x(j,3)?100:d){case 100:case 108:case 109:case 115:U(e,_,_,n&&C(Y(e,_,_,0,0,a,i,A,a,S=[],f),O),a,O,f,i,n?S:O);break;default:U(j,_,_,_,[""],O,0,i,O)}}u=l=h=0,g=w=1,A=j="",f=c;break;case 58:f=1+k(j),h=p;default:if(g<1)if(123==$)--g;else if(125==$&&0==g++&&125==R())continue;switch(j+=v($),$*g){case 38:w=l>0?1:(j+="\f",-1);break;case 44:i[u++]=(k(j)-1)*w,w=1;break;case 64:45===z()&&(j+=q(T())),d=z(),l=f=k(A=j+=X(I())),$++;break;case 45:45===p&&2==k(j)&&(g=0)}}return s}function Y(e,t,r,n,a,s,c,i,o,u,l){for(var d=a-1,h=0===a?s:[""],v=$(h),g=0,b=0,x=0;g<n;++g)for(var k=0,C=w(Line truncated
|
||||
//# sourceMappingURL=emotion-react-jsx-runtime.umd.min.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emotion-react-jsx-runtime.umd.min.js","sources":["../../../sheet/src/index.js","../../../../node_modules/stylis/src/Enum.js","../../../../node_modules/stylis/src/Utility.js","../../../../node_modules/stylis/src/Tokenizer.js","../../../../node_modules/stylis/src/Parser.js","../../../../node_modules/stylis/src/Serializer.js","../../../memoize/src/index.js","../../../cache/src/stylis-plugins.js","../../../cache/src/prefixer.js","../../../cache/src/index.js","../../../../node_modules/stylis/src/Middleware.js","../../src/utils.js","../../src/context.js","../../src/theming.js","../../../utils/src/index.js","../../../unitless/src/index.js","../../../serialize/src/index.js","../../../use-insertion-effect-with-fallbacks/src/index.js","../../src/emotion-element.js","../../../hash/src/index.js","../../src/jsx-runtime.js"],"sourcesContent":["// @flow\n/*\n\nBased off glamor's StyleSheet, thanks Sunil ❤️\n\nhigh performance StyleSheet for css-in-js systems\n\n- uses multiple style tags behind the scenes for millions of rules\n- uses `insertRule` for appending in production for *much* faster performance\n\n// usage\n\nimport { StyleSheet } from '@emotion/sheet'\n\nlet styleSheet = new StyleSheet({ key: '', container: document.head })\n\nstyleSheet.insert('#box { border: 1px solid red; }')\n- appends a css rule into the stylesheet\n\nstyleSheet.flush()\n- empties the stylesheet of all its contents\n\n*/\n\n// $FlowFixMe\nfunction sheetForTag(tag: HTMLStyleElement): CSSStyleSheet {\n if (tag.sheet) {\n // $FlowFixMe\n return tag.sheet\n }\n\n // this weirdness brought to you by firefox\n /* istanbul ignore next */\n for (let i = 0; i < document.styleSheets.length; i++) {\n if (document.styleSheets[i].ownerNode === tag) {\n // $FlowFixMe\n return document.styleSheets[i]\n }\n }\n}\n\nexport type Options = {\n nonce?: string,\n key: string,\n container: Node,\n speedy?: boolean,\n prepend?: boolean,\n insertionPoint?: HTMLElement\n}\n\nfunction createStyleElement(options: {\n key: string,\n nonce: string | void\n}): HTMLStyleElement {\n let tag = document.createElement('style')\n tag.setAttribute('data-emotion', options.key)\n if (options.nonce !== undefined) {\n tag.setAttribute('nonce', options.nonce)\n }\n tag.appendChild(document.createTextNode(''))\n tag.setAttribute('data-s', '')\n return tag\n}\n\nexport class StyleSheet {\n isSpeedy: boolean\n ctr: number\n tags: HTMLStyleElement[]\n // Using Node instead of HTMLElement since container may be a ShadowRoot\n container: Node\n key: string\n nonce: string | void\n prepend: boolean | void\n before: Element | null\n insertionPoint: HTMLElement | void\n constructor(options: Options) {\n this.isSpeedy =\n options.speedy === undefined\n ? process.env.NODE_ENV === 'production'\n : options.speedy\n this.tags = []\n this.ctr = 0\n this.nonce = options.nonce\n // key is the value of the data-emotion attribute, it's used to identify different sheets\n this.key = options.key\n this.container = options.container\n this.prepend = options.prepend\n this.insertionPoint = options.insertionPoint\n this.before = null\n }\n\n _insertTag = (tag: HTMLStyleElement) => {\n let before\n if (this.tags.length === 0) {\n if (this.insertionPoint) {\n before = this.insertionPoint.nextSibling\n } else if (this.prepend) {\n before = this.container.firstChild\n } else {\n before = this.before\n }\n } else {\n before = this.tags[this.tags.length - 1].nextSibling\n }\n this.container.insertBefore(tag, before)\n this.tags.push(tag)\n }\n\n hydrate(nodes: HTMLStyleElement[]) {\n nodes.forEach(this._insertTag)\n }\n\n insert(rule: string) {\n // the max length is how many rules we have per style tag, it's 65000 in speedy mode\n // it's 1 in dev because we insert source maps that map a single rule to a location\n // and you can only have one source map per style tag\n if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {\n this._insertTag(createStyleElement(this))\n }\n const tag = this.tags[this.tags.length - 1]\n\n if (process.env.NODE_ENV !== 'production') {\n const isImportRule =\n rule.charCodeAt(0) === 64 && rule.charCodeAt(1) === 105\n\n if (isImportRule && (this: any)._alreadyInsertedOrderInsensitiveRule) {\n // this would only cause problem in speedy mode\n // but we don't want enabling speedy to affect the observable behavior\n // so we report this error at all times\n console.error(\n `You're attempting to insert the following rule:\\n` +\n rule +\n '\\n\\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules.'\n )\n }\n\n ;(this: any)._alreadyInsertedOrderInLine truncated
|
||||
Generated
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
import * as ReactJSXRuntime from 'react/jsx-runtime';
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps } from '../../dist/emotion-element-3ac3b1d0.worker.esm.js';
|
||||
import 'react';
|
||||
import '@emotion/cache';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import '@emotion/weak-memoize';
|
||||
import '../../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
import '@emotion/utils';
|
||||
import '@emotion/serialize';
|
||||
import '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var Fragment = ReactJSXRuntime.Fragment;
|
||||
function jsx(type, props, key) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsx(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsx(Emotion, createEmotionProps(type, props), key);
|
||||
}
|
||||
function jsxs(type, props, key) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsxs(type, props, key);
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsxs(Emotion, createEmotionProps(type, props), key);
|
||||
}
|
||||
|
||||
export { Fragment, jsx, jsxs };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"main": "dist/emotion-react-jsx-runtime.cjs.js",
|
||||
"module": "dist/emotion-react-jsx-runtime.esm.js",
|
||||
"umd:main": "dist/emotion-react-jsx-runtime.umd.min.js",
|
||||
"browser": {
|
||||
"./dist/emotion-react-jsx-runtime.esm.js": "./dist/emotion-react-jsx-runtime.browser.esm.js"
|
||||
},
|
||||
"types": "../types/jsx-runtime",
|
||||
"sideEffects": false,
|
||||
"preconstruct": {
|
||||
"umdName": "emotionReactJSXRuntime"
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './macro.js'
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '@emotion/react'
|
||||
+1
@@ -0,0 +1 @@
|
||||
module.exports = require('@emotion/babel-plugin').macros.core
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
export * from './src/index.js'
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
{
|
||||
"name": "@emotion/react",
|
||||
"version": "11.11.4",
|
||||
"main": "dist/emotion-react.cjs.js",
|
||||
"module": "dist/emotion-react.esm.js",
|
||||
"browser": {
|
||||
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"worker": "./dist/emotion-react.worker.esm.js",
|
||||
"browser": "./dist/emotion-react.browser.esm.js",
|
||||
"default": "./dist/emotion-react.esm.js"
|
||||
},
|
||||
"import": "./dist/emotion-react.cjs.mjs",
|
||||
"default": "./dist/emotion-react.cjs.js"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
"module": {
|
||||
"worker": "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
|
||||
"browser": "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
|
||||
},
|
||||
"./_isolated-hnrs": {
|
||||
"module": {
|
||||
"worker": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
|
||||
"browser": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
|
||||
},
|
||||
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
"module": {
|
||||
"worker": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
|
||||
"browser": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
"types": {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"jsx-runtime",
|
||||
"jsx-dev-runtime",
|
||||
"_isolated-hnrs",
|
||||
"types/*.d.ts",
|
||||
"macro.*"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"author": "Emotion Contributors",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test:typescript": "dtslint types"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@emotion/babel-plugin": "^11.11.0",
|
||||
"@emotion/cache": "^11.11.0",
|
||||
"@emotion/serialize": "^1.1.3",
|
||||
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
|
||||
"@emotion/utils": "^1.2.1",
|
||||
"@emotion/weak-memoize": "^0.3.1",
|
||||
"hoist-non-react-statics": "^3.3.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.8.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@definitelytyped/dtslint": "0.0.112",
|
||||
"@emotion/css": "11.11.2",
|
||||
"@emotion/css-prettifier": "1.1.3",
|
||||
"@emotion/server": "11.11.0",
|
||||
"@emotion/styled": "11.11.0",
|
||||
"html-tag-names": "^1.1.2",
|
||||
"react": "16.14.0",
|
||||
"svg-tag-names": "^1.1.1",
|
||||
"typescript": "^4.5.5"
|
||||
},
|
||||
"repository": "https://github.com/emotion-js/emotion/tree/main/packages/react",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"umd:main": "dist/emotion-react.umd.min.js",
|
||||
"preconstruct": {
|
||||
"entrypoints": [
|
||||
"./index.js",
|
||||
"./jsx-runtime.js",
|
||||
"./jsx-dev-runtime.js",
|
||||
"./_isolated-hnrs.js"
|
||||
],
|
||||
"umdName": "emotionReact",
|
||||
"exports": {
|
||||
"envConditions": [
|
||||
"browser",
|
||||
"worker"
|
||||
],
|
||||
"extra": {
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
"types": {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -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
@@ -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)
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
// @flow
|
||||
import * as React from 'react'
|
||||
import {
|
||||
getRegisteredStyles,
|
||||
insertStyles,
|
||||
registerStyles
|
||||
} from '@emotion/utils'
|
||||
import { serializeStyles } from '@emotion/serialize'
|
||||
import { withEmotionCache } from './context'
|
||||
import { ThemeContext } from './theming'
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks'
|
||||
import { isBrowser } from './utils'
|
||||
|
||||
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 (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
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)
|
||||
}
|
||||
|
||||
type Props = {
|
||||
children: ({
|
||||
css: (...args: any) => string,
|
||||
cx: (...args: Array<ClassNameArg>) => string,
|
||||
theme: Object
|
||||
}) => React.Node
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
export const ClassNames: React.AbstractComponent<Props> =
|
||||
/* #__PURE__ */ withEmotionCache((props, cache) => {
|
||||
let hasRendered = false
|
||||
let serializedArr = []
|
||||
|
||||
let css = (...args: Array<any>) => {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
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 && process.env.NODE_ENV !== 'production') {
|
||||
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 (process.env.NODE_ENV !== 'production') {
|
||||
ClassNames.displayName = 'EmotionClassNames'
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
// @flow
|
||||
import { type EmotionCache } from '@emotion/utils'
|
||||
import * as React from 'react'
|
||||
import { useContext, forwardRef } from 'react'
|
||||
import createCache from '@emotion/cache'
|
||||
import { isBrowser } from './utils'
|
||||
|
||||
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 (process.env.NODE_ENV !== 'production') {
|
||||
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> {
|
||||
// $FlowFixMe
|
||||
return forwardRef((props: Props, ref: Ref) => {
|
||||
// the cache will never be null in the browser
|
||||
let cache = ((useContext(EmotionCacheContext): any): EmotionCache)
|
||||
|
||||
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 }
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// @flow
|
||||
|
||||
import type { Interpolation, SerializedStyles } from '@emotion/utils'
|
||||
import { serializeStyles } from '@emotion/serialize'
|
||||
|
||||
function css(...args: Array<Interpolation>): SerializedStyles {
|
||||
return serializeStyles(args)
|
||||
}
|
||||
|
||||
export default css
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
// @flow
|
||||
import * as React from 'react'
|
||||
import { withEmotionCache } from './context'
|
||||
import { ThemeContext } from './theming'
|
||||
import {
|
||||
getRegisteredStyles,
|
||||
insertStyles,
|
||||
registerStyles
|
||||
} from '@emotion/utils'
|
||||
import { hasOwn, isBrowser } from './utils'
|
||||
import { serializeStyles } from '@emotion/serialize'
|
||||
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 (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
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
|
||||
|
||||
// For performance, only call getLabelFromStackTrace in development and when
|
||||
// the label hasn't already been computed
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
!!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 (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
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 &&
|
||||
(process.env.NODE_ENV === 'production' || key !== labelPropName)
|
||||
) {
|
||||
newProps[key] = props[key]
|
||||
}
|
||||
}
|
||||
newProps.ref = ref
|
||||
newProps.className = className
|
||||
|
||||
return (
|
||||
<>
|
||||
<Insertion
|
||||
cache={cache}
|
||||
serialized={serialized}
|
||||
isStringTag={typeof WrappedComponent === 'string'}
|
||||
/>
|
||||
<WrappedComponent {...newProps} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Emotion.displayName = 'EmotionCssPropInternal'
|
||||
}
|
||||
|
||||
export default Emotion
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// @flow
|
||||
|
||||
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: string) =>
|
||||
identifier.replace(/\$/g, '-')
|
||||
|
||||
export const getLabelFromStackTrace = (stackTrace: string): ?string => {
|
||||
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
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
// @flow
|
||||
import * as React from 'react'
|
||||
import { withEmotionCache } from './context'
|
||||
import { ThemeContext } from './theming'
|
||||
import { insertStyles } from '@emotion/utils'
|
||||
import { isBrowser } from './utils'
|
||||
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 (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
!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
|
||||
// $FlowFixMe 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
|
||||
// $FlowFixMe
|
||||
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: any)
|
||||
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: any): Element | null)
|
||||
sheet.flush()
|
||||
}
|
||||
cache.insert(``, serialized, sheet, false)
|
||||
}, [cache, serialized.name])
|
||||
|
||||
return null
|
||||
})
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Global.displayName = 'EmotionGlobal'
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '../types/index'
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
// @flow
|
||||
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 (process.env.NODE_ENV !== 'production') {
|
||||
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
@@ -0,0 +1 @@
|
||||
export * from '../types/jsx-dev-runtime'
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// @flow
|
||||
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: any,
|
||||
props: any,
|
||||
key: any,
|
||||
isStaticChildren: any,
|
||||
source: any,
|
||||
self: any
|
||||
) {
|
||||
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
@@ -0,0 +1 @@
|
||||
export * from '../types/jsx-runtime'
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// @flow
|
||||
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: any, props: any, key: any) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsx(type, props, key)
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsx(Emotion, createEmotionProps(type, props), key)
|
||||
}
|
||||
|
||||
export function jsxs(type: any, props: any, key: any) {
|
||||
if (!hasOwn.call(props, 'css')) {
|
||||
return ReactJSXRuntime.jsxs(type, props, key)
|
||||
}
|
||||
|
||||
return ReactJSXRuntime.jsxs(Emotion, createEmotionProps(type, props), key)
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// @flow
|
||||
import * as React from 'react'
|
||||
import Emotion, { createEmotionProps } from './emotion-element'
|
||||
import { hasOwn } from './utils'
|
||||
|
||||
// $FlowFixMe
|
||||
export const jsx: typeof React.createElement = function (
|
||||
type: React.ElementType,
|
||||
props: Object
|
||||
) {
|
||||
let args = arguments
|
||||
|
||||
if (props == null || !hasOwn.call(props, 'css')) {
|
||||
// $FlowFixMe
|
||||
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]
|
||||
}
|
||||
|
||||
// $FlowFixMe
|
||||
return React.createElement.apply(null, createElementArgArray)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// @flow
|
||||
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}`
|
||||
// $FlowFixMe
|
||||
return {
|
||||
name,
|
||||
styles: `@keyframes ${name}{${insertable.styles}}`,
|
||||
anim: 1,
|
||||
toString() {
|
||||
return `_EMO_${this.name}_${this.styles}_EMO_`
|
||||
}
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
// @flow
|
||||
import * as React from 'react'
|
||||
import weakMemoize from '@emotion/weak-memoize'
|
||||
import hoistNonReactStatics from './_isolated-hnrs'
|
||||
|
||||
export const ThemeContext = /* #__PURE__ */ React.createContext<Object>({})
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
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 (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
(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 (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
(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} />
|
||||
}
|
||||
// $FlowFixMe
|
||||
let WithTheme = React.forwardRef(render)
|
||||
|
||||
WithTheme.displayName = `WithTheme(${componentName})`
|
||||
|
||||
return hoistNonReactStatics(WithTheme, Component)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// @flow
|
||||
export let isBrowser = typeof document !== 'undefined'
|
||||
|
||||
export const hasOwn = {}.hasOwnProperty
|
||||
Loaded 100 of 6977 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user