@emotion/styled-base
Advanced tools
Comparing version 0.2.3 to 0.3.0
@@ -105,43 +105,40 @@ 'use strict'; | ||
_this = _React$Component.call(this, props) || this; | ||
Object.defineProperty(_assertThisInitialized(_this), "renderChild", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: function value(context) { | ||
var className = ''; | ||
var classInterpolations = []; | ||
_this.mergedProps = omitAssign(testAlwaysTrue, {}, _this.props, { | ||
theme: context.theme || _this.props.theme || {} | ||
}); | ||
_this.shouldHydrate = core.hydration.shouldHydrate; | ||
if (typeof _this.props.className === 'string') { | ||
className += utils.getRegisteredStyles(context.registered, classInterpolations, _this.props.className); | ||
} | ||
_this.renderChild = function (context) { | ||
var className = ''; | ||
var classInterpolations = []; | ||
_this.mergedProps = omitAssign(testAlwaysTrue, {}, _this.props, { | ||
theme: context.theme || _this.props.theme || {} | ||
}); | ||
var serialized = serialize.serializeStyles.call(_assertThisInitialized(_this), styles.concat(classInterpolations)); | ||
var rules = utils.insertStyles(context, serialized); | ||
className += serialized.cls; | ||
if (typeof _this.props.className === 'string') { | ||
className += utils.getRegisteredStyles(context.registered, classInterpolations, _this.props.className); | ||
} | ||
if (_this.serialized === undefined && _this.shouldHydrate) { | ||
_this.serialized = rules; | ||
} | ||
var serialized = serialize.serializeStyles.call(_assertThisInitialized(_this), styles.concat(classInterpolations)); | ||
var rules = utils.insertStyles(context, serialized); | ||
className += serialized.cls; | ||
var ele = React.createElement(baseTag, omitAssign(omitFn, {}, _this.props, { | ||
className: className, | ||
ref: _this.props.innerRef | ||
})); | ||
if (_this.serialized === undefined && _this.shouldHydrate) { | ||
_this.serialized = rules; | ||
} | ||
if (_this.shouldHydrate && _this.serialized !== undefined) { | ||
return React.createElement(React.Fragment, null, React.createElement("style", { | ||
"data-more": serialized.name, | ||
dangerouslySetInnerHTML: { | ||
__html: _this.serialized | ||
} | ||
}), ele); | ||
} | ||
var ele = React.createElement(baseTag, omitAssign(omitFn, {}, _this.props, { | ||
className: className, | ||
ref: _this.props.innerRef | ||
})); | ||
return ele; | ||
if (_this.shouldHydrate && _this.serialized !== undefined) { | ||
return React.createElement(React.Fragment, null, React.createElement("style", { | ||
"data-more": serialized.name, | ||
dangerouslySetInnerHTML: { | ||
__html: _this.serialized | ||
} | ||
}), ele); | ||
} | ||
}); | ||
_this.shouldHydrate = core.hydration.shouldHydrate; | ||
return ele; | ||
}; | ||
return _this; | ||
@@ -156,6 +153,6 @@ } | ||
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') + ")"; | ||
Styled[emotionUtils.STYLES_KEY] = styles; | ||
Styled.__emotion_base = baseTag; | ||
Styled.__emotion_real = Styled; | ||
@@ -162,0 +159,0 @@ Styled.withComponent = function (nextTag, nextOptions) { |
@@ -103,43 +103,40 @@ import { memoize, STYLES_KEY } from 'emotion-utils'; | ||
_this = _React$Component.call(this, props) || this; | ||
Object.defineProperty(_assertThisInitialized(_this), "renderChild", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: function value(context) { | ||
var className = ''; | ||
var classInterpolations = []; | ||
_this.mergedProps = omitAssign(testAlwaysTrue, {}, _this.props, { | ||
theme: context.theme || _this.props.theme || {} | ||
}); | ||
_this.shouldHydrate = hydration.shouldHydrate; | ||
if (typeof _this.props.className === 'string') { | ||
className += getRegisteredStyles(context.registered, classInterpolations, _this.props.className); | ||
} | ||
_this.renderChild = function (context) { | ||
var className = ''; | ||
var classInterpolations = []; | ||
_this.mergedProps = omitAssign(testAlwaysTrue, {}, _this.props, { | ||
theme: context.theme || _this.props.theme || {} | ||
}); | ||
var serialized = serializeStyles.call(_assertThisInitialized(_this), styles.concat(classInterpolations)); | ||
var rules = insertStyles(context, serialized); | ||
className += serialized.cls; | ||
if (typeof _this.props.className === 'string') { | ||
className += getRegisteredStyles(context.registered, classInterpolations, _this.props.className); | ||
} | ||
if (_this.serialized === undefined && _this.shouldHydrate) { | ||
_this.serialized = rules; | ||
} | ||
var serialized = serializeStyles.call(_assertThisInitialized(_this), styles.concat(classInterpolations)); | ||
var rules = insertStyles(context, serialized); | ||
className += serialized.cls; | ||
var ele = createElement(baseTag, omitAssign(omitFn, {}, _this.props, { | ||
className: className, | ||
ref: _this.props.innerRef | ||
})); | ||
if (_this.serialized === undefined && _this.shouldHydrate) { | ||
_this.serialized = rules; | ||
} | ||
if (_this.shouldHydrate && _this.serialized !== undefined) { | ||
return createElement(Fragment, null, createElement("style", { | ||
"data-more": serialized.name, | ||
dangerouslySetInnerHTML: { | ||
__html: _this.serialized | ||
} | ||
}), ele); | ||
} | ||
var ele = createElement(baseTag, omitAssign(omitFn, {}, _this.props, { | ||
className: className, | ||
ref: _this.props.innerRef | ||
})); | ||
return ele; | ||
if (_this.shouldHydrate && _this.serialized !== undefined) { | ||
return createElement(Fragment, null, createElement("style", { | ||
"data-more": serialized.name, | ||
dangerouslySetInnerHTML: { | ||
__html: _this.serialized | ||
} | ||
}), ele); | ||
} | ||
}); | ||
_this.shouldHydrate = hydration.shouldHydrate; | ||
return ele; | ||
}; | ||
return _this; | ||
@@ -154,6 +151,6 @@ } | ||
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') + ")"; | ||
Styled[STYLES_KEY] = styles; | ||
Styled.__emotion_base = baseTag; | ||
Styled.__emotion_real = Styled; | ||
@@ -160,0 +157,0 @@ Styled.withComponent = function (nextTag, nextOptions) { |
{ | ||
"name": "@emotion/styled-base", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "base styled API for emotion", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -10,3 +10,2 @@ // @flow | ||
omitAssign, | ||
type Interpolations, | ||
type StyledOptions, | ||
@@ -60,17 +59,32 @@ type CreateStyled | ||
class Styled extends React.Component<*> { | ||
static __emotion_real = Styled | ||
static __emotion_base = baseTag | ||
static __emotion_styles = styles | ||
static displayName = identifierName !== undefined | ||
? identifierName | ||
: `Styled(${ | ||
typeof baseTag === 'string' | ||
? baseTag | ||
: baseTag.displayName || baseTag.name || 'Component' | ||
})` | ||
static withComponent = ( | ||
nextTag: ElementType, | ||
nextOptions?: StyledOptions | ||
) => { | ||
return createStyled( | ||
nextTag, | ||
nextOptions !== undefined | ||
? // $FlowFixMe | ||
omitAssign(testAlwaysTrue, {}, options, nextOptions) | ||
: options | ||
)(...args) | ||
} | ||
mergedProps: Object | ||
shouldHydrate: boolean | ||
serialized: string | ||
static toString: () => string | ||
static __emotion_real: any | ||
static __emotion_styles: Interpolations | ||
static __emotion_base: Styled | ||
static withComponent: (ElementType, options?: StyledOptions) => any | ||
constructor(props) { | ||
super(props) | ||
this.shouldHydrate = hydration.shouldHydrate | ||
} | ||
componentDidMount() { | ||
hydration.shouldHydrate = false | ||
} | ||
shouldHydrate = hydration.shouldHydrate | ||
renderChild = (context: CSSContextType) => { | ||
@@ -120,2 +134,6 @@ let className = '' | ||
} | ||
componentDidMount() { | ||
hydration.shouldHydrate = false | ||
} | ||
render() { | ||
@@ -125,28 +143,3 @@ return consumer(this, this.renderChild) | ||
} | ||
Styled.displayName = | ||
identifierName !== undefined | ||
? identifierName | ||
: `Styled(${ | ||
typeof baseTag === 'string' | ||
? baseTag | ||
: baseTag.displayName || baseTag.name || 'Component' | ||
})` | ||
Styled[STYLES_KEY] = styles | ||
Styled.__emotion_base = baseTag | ||
Styled.__emotion_real = Styled | ||
Styled.withComponent = ( | ||
nextTag: ElementType, | ||
nextOptions?: StyledOptions | ||
) => { | ||
return createStyled( | ||
nextTag, | ||
nextOptions !== undefined | ||
? // $FlowFixMe | ||
omitAssign(testAlwaysTrue, {}, options, nextOptions) | ||
: options | ||
)(...args) | ||
} | ||
return Styled | ||
@@ -153,0 +146,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
92215
922