@emotion/styled-base
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -9,2 +9,20 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
@@ -140,15 +158,26 @@ subClass.prototype = Object.create(superClass.prototype); | ||
return Styled; | ||
}(React.Component); | ||
}(React.Component); // $FlowFixMe | ||
Styled.__emotion_real = Styled; | ||
Styled.__emotion_base = baseTag; | ||
Styled.__emotion_styles = styles; | ||
Styled.displayName = identifierName !== undefined ? identifierName : "Styled(" + (typeof baseTag === 'string' ? baseTag : baseTag.displayName || baseTag.name || 'Component') + ")"; | ||
var FinalStyled = React.forwardRef(function (props, ref) { | ||
if (ref === null) { | ||
// this avoids creating a new object if there's no ref | ||
return React.createElement(Styled, props); | ||
} | ||
Styled.withComponent = function (nextTag, nextOptions) { | ||
return React.createElement(Styled, _extends({}, props, { | ||
innerRef: ref | ||
})); | ||
}); | ||
FinalStyled.__emotion_real = FinalStyled; | ||
FinalStyled.__emotion_base = baseTag; | ||
FinalStyled.__emotion_styles = styles; | ||
FinalStyled.withComponent = function (nextTag, nextOptions) { | ||
return createStyled(nextTag, nextOptions !== undefined ? // $FlowFixMe | ||
omitAssign(testAlwaysTrue, {}, options, nextOptions) : options).apply(void 0, args); | ||
omitAssign(testAlwaysTrue, {}, options, nextOptions) : options).apply(void 0, styles); | ||
}; | ||
return Styled; | ||
return FinalStyled; | ||
}; | ||
@@ -155,0 +184,0 @@ }; |
import { memoize, STYLES_KEY } from 'emotion-utils'; | ||
import { createElement, Fragment, Component } from 'react'; | ||
import { createElement, Fragment, Component, forwardRef } from 'react'; | ||
import { consumer } from '@emotion/core'; | ||
@@ -7,2 +7,20 @@ import { getRegisteredStyles, insertStyles, shouldSerializeToReactTree } from '@emotion/utils'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
@@ -138,15 +156,26 @@ subClass.prototype = Object.create(superClass.prototype); | ||
return Styled; | ||
}(Component); | ||
}(Component); // $FlowFixMe | ||
Styled.__emotion_real = Styled; | ||
Styled.__emotion_base = baseTag; | ||
Styled.__emotion_styles = styles; | ||
Styled.displayName = identifierName !== undefined ? identifierName : "Styled(" + (typeof baseTag === 'string' ? baseTag : baseTag.displayName || baseTag.name || 'Component') + ")"; | ||
var FinalStyled = forwardRef(function (props, ref) { | ||
if (ref === null) { | ||
// this avoids creating a new object if there's no ref | ||
return createElement(Styled, props); | ||
} | ||
Styled.withComponent = function (nextTag, nextOptions) { | ||
return createElement(Styled, _extends({}, props, { | ||
innerRef: ref | ||
})); | ||
}); | ||
FinalStyled.__emotion_real = FinalStyled; | ||
FinalStyled.__emotion_base = baseTag; | ||
FinalStyled.__emotion_styles = styles; | ||
FinalStyled.withComponent = function (nextTag, nextOptions) { | ||
return createStyled(nextTag, nextOptions !== undefined ? // $FlowFixMe | ||
omitAssign(testAlwaysTrue, {}, options, nextOptions) : options).apply(void 0, args); | ||
omitAssign(testAlwaysTrue, {}, options, nextOptions) : options).apply(void 0, styles); | ||
}; | ||
return Styled; | ||
return FinalStyled; | ||
}; | ||
@@ -153,0 +182,0 @@ }; |
{ | ||
"name": "@emotion/styled-base", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "base styled API for emotion", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -62,5 +62,2 @@ // @flow | ||
class Styled extends React.Component<*> { | ||
static __emotion_real = Styled | ||
static __emotion_base = baseTag | ||
static __emotion_styles = styles | ||
static displayName = identifierName !== undefined | ||
@@ -73,16 +70,2 @@ ? identifierName | ||
})` | ||
static withComponent = ( | ||
nextTag: ElementType, | ||
nextOptions?: StyledOptions | ||
) => { | ||
return createStyled( | ||
nextTag, | ||
nextOptions !== undefined | ||
? // $FlowFixMe | ||
omitAssign(testAlwaysTrue, {}, options, nextOptions) | ||
: options | ||
)(...args) | ||
} | ||
mergedProps: Object | ||
@@ -134,4 +117,28 @@ | ||
} | ||
// $FlowFixMe | ||
const FinalStyled = React.forwardRef((props, ref) => { | ||
if (ref === null) { | ||
// this avoids creating a new object if there's no ref | ||
return <Styled {...props} /> | ||
} | ||
return <Styled {...props} innerRef={ref} /> | ||
}) | ||
return Styled | ||
FinalStyled.__emotion_real = FinalStyled | ||
FinalStyled.__emotion_base = baseTag | ||
FinalStyled.__emotion_styles = styles | ||
FinalStyled.withComponent = ( | ||
nextTag: ElementType, | ||
nextOptions?: StyledOptions | ||
) => { | ||
return createStyled( | ||
nextTag, | ||
nextOptions !== undefined | ||
? // $FlowFixMe | ||
omitAssign(testAlwaysTrue, {}, options, nextOptions) | ||
: options | ||
)(...styles) | ||
} | ||
return FinalStyled | ||
} | ||
@@ -138,0 +145,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93901
955