Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 2x 3x 7x 7x 2x | /*
Copyright (c) 2018-2019 Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
// @flow
import * as React from 'react';
import {createStyled} from 'styletron-react';
import {driver, getInitialStyle} from 'styletron-standard';
import type {StyleObject} from 'styletron-standard';
import type {ThemeT} from './types.js';
import {ThemeContext} from './theme-provider.js';
const wrapper = StyledComponent => {
return React.forwardRef((props, ref) => (
<ThemeContext.Consumer>
{theme => <StyledComponent ref={ref} {...props} $theme={theme} />}
</ThemeContext.Consumer>
));
};
/* eslint-disable flowtype/generic-spacing */
/* eslint-disable flowtype/no-weak-types */
type StyletronComponent<Props> = React.StatelessFunctionalComponent<Props> & {
__STYLETRON__: any,
};
type StyleFn = {
(string, StyleObject): StyletronComponent<{}>,
<Props>(
string,
({$theme: ThemeT} & Props) => StyleObject,
): StyletronComponent<Props>,
<Props, CustomTheme>(
string,
({$theme: CustomTheme} & Props) => StyleObject,
): StyletronComponent<Props>,
<Base: React.ComponentType<any>>(
Base,
StyleObject,
): StyletronComponent<$Diff<React.ElementConfig<Base>, {className: any}>>,
<Base: React.ComponentType<any>, Props>(
Base,
({$theme: ThemeT} & Props) => StyleObject,
): StyletronComponent<
$Diff<React.ElementConfig<Base>, {className: any}> & Props,
>,
<Base: React.ComponentType<any>, Props, CustomTheme>(
Base,
({$theme: CustomTheme} & Props) => StyleObject,
): StyletronComponent<
$Diff<React.ElementConfig<Base>, {className: any}> & Props,
>,
};
/* eslint-enable flowtype/generic-spacing */
/* eslint-enable flowtype/no-weak-types */
const styled = ((createStyled({
wrapper,
getInitialStyle,
driver,
// eslint-disable-next-line flowtype/no-weak-types
}): any): StyleFn);
export default styled;
|