Skip to content

Latest commit

Β 

History

History
511 lines (324 loc) Β· 38.5 KB

CHANGELOG.md

File metadata and controls

511 lines (324 loc) Β· 38.5 KB

@emotion/styled

11.8.0

Minor Changes

  • #2600 2f27156a Thanks @Andarist! - Refactored code to use the upcoming React.useInsertionEffect when it's available (this is a new hook that is going to be introduced in React 18). This shouldn't have any effect on existing codebases and the change should be transparent.

Patch Changes

  • Updated dependencies [d2531639, 2f27156a]:
    • @emotion/is-prop-valid@1.1.2
    • @emotion/utils@1.1.0

11.6.0

Minor Changes

  • #2542 eb013d25 Thanks @eps1lon! - Fixed hydration mismatches if React.useId (an upcoming API in React 18) is used within a tree below our components.

Patch Changes

  • Updated dependencies [9861a18b]:
    • @emotion/is-prop-valid@1.1.1

11.3.0

Patch Changes

11.1.5

Patch Changes

  • d0293508 #2240 Thanks @wolszczak96! - as prop has been removed from TypeScript declarations for composite components. This prop has not actually been handled by default by styled for those components - to make styled handle it you need to provide a custom shouldForwardProp that doesn't forward the as prop.

  • Updated dependencies [f3c2e81d]:

    • @emotion/is-prop-valid@1.1.0

11.0.0

Major Changes

  • f9feab1a #1575 Thanks @mitchellhamilton! - Removed support for @emotion/styled-base package. It has been moved to @emotion/styled and is available as @emotion/styled/base. This simplifies how the regular and base versions relate to each other and eliminates problems with stricter package managers when @emotion/styled-base was not installed explicitly by a user.
  • 79036056 #967 Thanks @mitchellhamilton! - Remove support for deprecated innerRef prop

  • a72e6dc #1501 Thanks @JakeGinnivan! - TypeScript types have been significantly restructured. These changes:

    • reduce build times when using Emotion, especially in larger projects
    • it's no longer necessary to manually specify generic parameters for your Emotion components in many cases
    • union types as props are better supported and should be inferred properly
    • the css function has been restricted to prevent passing invalid types
    • styled's generic parameter has been changed, if you were specifying the ComponentType you will need to remove that generic parameter
    • styled no longer takes a second ExtraProps parameter - instead of that move it to after the styled call. So instead of writing styled<typeof MyComponent, ExtraProps>(MyComponent)({}) you should now be writing styled(MyComponent)<ExtraProps>({})

    If you encounter build issues after upgrade, try removing any manually specified generic types and let them be inferred.

  • c6431074 #1609 Thanks @tomsseisums! - It's now easier to provide a type for Theme. Instead of creating custom instances (like before) you can augment the builtin Theme interface like this:

    import '@emotion/react'
    
    declare module '@emotion/react' {
      export interface Theme {
        primaryColor: string
        secondaryColor: string
      }
    }
  • 105de5c8 #1572 Thanks @Andarist! - [data-emotion] attribute on SSRed styled has changed. You should never rely on it though.

  • 9e998e37 #1817 Thanks @Andarist! - The parser we use (Stylis) got upgraded. It fixes some long-standing parsing edge cases while being smaller and faster πŸš€

    It has been completely rewritten and comes with some breaking changes. The most notable ones that might affect Emotion users are:

    • plugins written for the former Stylis v3 are not compatible with the new version. To learn more on how to write a plugin for Stylis v4 you can check out its README and the source code of core plugins.
    • vendor-prefixing was previously customizable using prefix option. This was always limited to turning off all of some of the prefixes as all available prefixes were on by default. The prefix option is gone and to customize which prefixes are applied you need to fork (copy-paste) the prefixer plugin and adjust it to your needs. While this being somewhat more problematic to setup at first we believe that the vast majority of users were not customizing this anyway. By not including the possibility to customize this through an extra option the final solution is more performant because there is no extra overhead of checking if a particular property should be prefixed or not.
    • the prefixer is now just a plugin which happens to be included in the default stylisPlugins. If you plan to use custom stylisPlugins and you want to have your styles prefixed automatically you must include prefixer in your custom stylisPlugins. You can import prefixer from the stylis module to do that.
    • @import rules are no longer special-cased. The responsibility to put them first has been moved to the author of the styles. They also can't be nested within other rules now. It's only possible to write them at the top level of global styles.

Minor Changes

  • 4d3b60d0 #1874 Thanks @connor-baer! - Added basic TS type support for as prop on styled components. It's possible to pass any component to it but it has no effect on other accepted props. This means that it's not 100% type-safe so use it sparingly and with care.
  • ad77ed24 #1624 Thanks @JakeGinnivan! - Added CreateStyled overload to handle when shouldForwardProp is a custom type guard for intrinsic props.

    As an example, if you want to override the type of the color prop:

    export const Box = styled('div', {
      shouldForwardProp: (
        propName
      ): propName is Exclude<keyof JSX.IntrinsicElements['div'], 'color'> =>
        propName !== 'color'
    })<{ color: Array<string> }>(props => ({
      color: props.color[0]
    }))
    ;<Box color={['green']} />
  • 18c0d5f4 #1668 Thanks @animecyc! - Custom shouldForwardProp is being preserved now when using .withComponent. Also, when passing an additional shouldForwardProp in .withComponent's options (like this: SomeComponent.withComponent('span', { shouldForwardProp })) it's being composed with the potentially existing shouldForwardProp.
  • 5d692a6a #1956 Thanks @eps1lon! - Upgraded csstype dependency to its v3. This is what we use to provide TypeScript typings for object styles. The upgrade should not affect any consuming code but it's worth mentioning if any edge case scenarios arise.

Patch Changes

  • 22935470 #1588 Thanks @FezVrasta! - StyledComponent Flow type is now polymorphic, that means you can now define the component prop types to get better type safety.
  • 58dc08a6 #1837 Thanks @arcanis! - Fixed TS compatibility under PnP environments by making @types/react an optional peer dependency.

11.0.0-rc.0

Major Changes

Patch Changes

  • Updated dependencies [9c4ebc16, 69446cb5]:
    • @emotion/babel-plugin@11.0.0-rc.0
    • @emotion/is-prop-valid@1.0.0-rc.0
    • @emotion/react@11.0.0-rc.0
    • @emotion/serialize@1.0.0-rc.0
    • @emotion/utils@1.0.0-rc.0

11.0.0-next.19

Patch Changes

  • Updated dependencies []:
    • @emotion/react@11.0.0-next.19

11.0.0-next.17

Patch Changes

  • Updated dependencies [76e3dc4d]:
    • @emotion/serialize@1.0.0-next.5
    • @emotion/babel-plugin@11.0.0-next.17
    • @emotion/react@11.0.0-next.17

11.0.0-next.16

Minor Changes

  • 18c0d5f4 #1668 Thanks @animecyc! - Custom shouldForwardProp is being preserved now when using .withComponent. Also, when passing an additional shouldForwardProp in .withComponent's options (like this: SomeComponent.withComponent('span', { shouldForwardProp })) it's being composed with the potentially existing shouldForwardProp.

Patch Changes

  • 23faf9ef #1996 Thanks @Andarist! - Fixed an issue with wrapped class components not having a type for the ref prop.
  • 0895f1f3 #1995 Thanks @Andarist! - Fixed an issue with typing for the as prop not being provided to components created using component factories available on the styled factory (e.g. styled.div).

  • Updated dependencies [debaad9a, 58b2bbca]:

    • @emotion/utils@1.0.0-next.1
    • @emotion/react@11.0.0-next.16
    • @emotion/serialize@0.11.15-next.4
    • @emotion/babel-plugin@11.0.0-next.16

11.0.0-next.15

Minor Changes

  • 5d692a6a #1956 Thanks @eps1lon! - Upgraded csstype dependency to its v3. This is what we use to provide TypeScript typings for object styles. The upgrade should not affect any consuming code but it's worth mentioning if any edge case scenarios arise.

Patch Changes

  • Updated dependencies [5d692a6a]:
    • @emotion/react@11.0.0-next.15
    • @emotion/serialize@1.0.0-next.3
    • @emotion/babel-plugin@11.0.0-next.15

11.0.0-next.14

Minor Changes

  • 4d3b60d0 #1874 Thanks @connor-baer! - Added basic TS type support for as prop on styled components. It's possible to pass any component to it but it has no effect on other accepted props. This means that it's not 100% type-safe so use it sparingly and with care.

Patch Changes

  • 58dc08a6 #1837 Thanks @arcanis! - Fixed TS compatibility under PnP environments by making @types/react an optional peer dependency.

  • Updated dependencies [58dc08a6, f57a7229]:

    • @emotion/react@11.0.0-next.14

11.0.0-next.13

Major Changes

  • 9e998e37 #1817 Thanks @Andarist! - The parser we use (Stylis) got upgraded. It fixes some long-standing parsing edge cases while being smaller and faster πŸš€

    It has been completely rewritten and comes with some breaking changes. Most notable ones that might affect Emotion users are:

    • plugins written for the former Stylis v3 are not compatible with the new version. To learn more on how to write a plugin for Stylis v4 you can check out its README and the source code of core plugins.
    • vendor-prefixing was previously customizable using prefix option. This was always limited to turning off all of some of the prefixes as all available prefixes were on by default. The prefix option is gone and to customize which prefixes are applied you need to fork (copy-paste) the prefixer plugin and adjust it to your needs. While this being somewhat more problematic to setup at first we believe that the vast majority of users were not customizing this anyway. By not including the possibility to customize this through an extra option the final solution is more performant because there is no extra overhead of checking if a particular property should be prefixed or not.
    • Prefixer is now just a plugin which happens to be put in default stylisPlugins. If you plan to use custom stylisPlugins and you want to have your styles prefixed automatically you must include prefixer in your custom stylisPlugins. You can import prefixer from the stylis module to do that.
    • @import rules are no longer special-cased. The responsibility to put them first has been moved to the author of the styles. They also can't be nested within other rules now. It's only possible to write them at the top level of global styles.

Patch Changes

  • Updated dependencies [5e803106, 9e998e37, 9e998e37, 9e998e37]:
    • @emotion/babel-plugin@11.0.0-next.13
    • @emotion/react@11.0.0-next.13
    • @emotion/utils@1.0.0-next.0
    • @emotion/serialize@0.11.15-next.2

11.0.0-next.12

Major Changes

  • 105de5c8 #1572 Thanks @Andarist! - [data-emotion] attribute on SSRed styled has changed. You should never rely on it though.

Patch Changes

11.0.0-next.11

Patch Changes

  • b79781f8 #1708 Thanks @fabien0102! - Fix props.theme type in styled component interpolation being optional (Theme | undefined) for components without AdditionalProps being specified.
  • Updated dependencies [f08ef5a3]:
    • @emotion/serialize@0.11.15-next.4
    • @emotion/babel-plugin@11.0.0-next.11
    • @emotion/react@11.0.0-next.11

11.0.0-next.10

Patch Changes

11.0.0-next.9

Patch Changes

  • 8b59959 #1659 Thanks @Andarist! - Fixed issue when using "component as selector" in styled interpolations which caused the wrong type to be inferred.
  • Updated dependencies []:
    • @emotion/core@11.0.0-next.9

11.0.0-next.8

Major Changes

  • c643107 #1609 Thanks @joltmode! - Reworked TypeScript definitions so it's easier to provide a type for Theme. Instead of creating custom instances (like before) you can augment builtin Theme interface like this:

    declare module '@emotion/core' {
      export interface Theme {
        primaryColor: string
        secondaryColor: string
      }
    }

Patch Changes

  • Updated dependencies [c643107, c643107, c643107, c643107]:
    • babel-plugin-emotion@11.0.0-next.8
    • @emotion/core@11.0.0-next.8
    • @emotion/serialize@0.12.0-next.3

11.0.0-next.7

Patch Changes

  • Updated dependencies [5c55fd17, 729ef9d8]:
    • @emotion/core@11.0.0-next.7
    • @emotion/serialize@0.11.15-next.2

11.0.0-next.6

Patch Changes

11.0.0-next.5

Minor Changes

  • ad77ed24 #1624 Thanks @JakeGinnivan! - Added CreateStyled overload to handle when shouldForwardProp is a custom type guard for intrinsic props.

    As an example, if you want to override the type of the color prop:

    export const Box = styled('div', {
      shouldForwardProp: (
        propName
      ): propName is Exclude<keyof JSX.IntrinsicElements['div'], 'color'> =>
        propName !== 'color'
    })<{ color: Array<string> }>(props => ({
      color: props.color[0]
    }))
    ;<Box color={['green']} />

Patch Changes

  • 99c6b7e2 #1632 Thanks @JakeGinnivan! - Fix issue with one of TypeScript overloads for styled. It pass StyleProps to Interpolation correctly now.
  • Updated dependencies []:
    • @emotion/core@11.0.0-next.5

11.0.0-next.4

Patch Changes

  • e6e079c3 #1627 Thanks @frankwallis! - Fix for TypeScript error when importing @emotion/styled/base in combination with isolatedModules option.
  • Updated dependencies [c65c5d88]:
    • babel-plugin-emotion@11.0.0-next.4
    • @emotion/core@11.0.0-next.4

11.0.0-next.3

Major Changes

  • f9feab1a #1575 Thanks @mitchellhamilton! - Removed support for @emotion/styled-base package. It has been moved to @emotion/styled and is available as @emotion/styled/base. This simplifies how the regular and base versions relate to each other and eliminates problems with stricter package managers when @emotion/styled-base was not installed explicitly by a user.

Patch Changes

11.0.0-next.2

Major Changes

Patch Changes

  • Updated dependencies [79036056, 79036056]:
    • @emotion/styled-base@11.0.0-next.2
    • @emotion/core@11.0.0-next.2

11.0.0-next.1

Major Changes

  • a72e6dc0 #1501 Thanks @JakeGinnivan! - TypeScript types have been restructured. These changes:

    • Reduce build times when using emotion
    • In many cases remove the need for manually specifying generic parameters for your emotion components.

    If you encounter build issues after upgrade, try removing any manually specified generic types and let them be inferred. Otherwise refer to the breaking changes list below.

    Improvements

    • useTheme added to EmotionTheming interface and can now create your own closed variation of withTheme. More information in the docs under the theming section.
    • Union types as props are better supported and should be inferred properly
    • Build times should be reduced significantly in larger projects.

    Breaking changes

    • withTheme can now have the Theme type specified when calling it. For example withTheme<MyTheme>(MyComponent)

      Breaking change: Generic argument changed, if you were specifying the ComponentType you will need to remove the generic parameter. Recommend following example setup in the TypeScript docs under theming section

    • css function has been restricted to prevent passing of invalid types

    • CreateStyled functions no longer take a second ExtraProps argument. Instead move it to after the create styled call. For example

      styled<typeof MyComponent, ExtraProps>(MyComponent)({}) to styled(MyComponent)<ExtraProps>({})

    • StyledComponent type no longer supports the third generic Theme parameter. Instead add the theme prop to the first Props argument. For example:

      StyledComponent<Props, {}, MyTheme> to StyledComponent<Props & { theme?: MyTheme }>

Patch Changes

  • 22935470 #1588 Thanks @FezVrasta! - StyledComponent Flow type is now polymorphic, that means you can now define the component prop types to get better type safety.
  • Updated dependencies [1eaa3a38, 22935470]:
    • @emotion/styled-base@11.0.0-next.1
    • babel-plugin-emotion@11.0.0-next.1
    • @emotion/core@11.0.0-next.1

11.0.0-next.0

Major Changes

  • 302bdba1 #1600 Thanks @mitchellhamilton! - Ensure packages are major bumped so that pre-release versions of the linked packages are consistent in the major number

Patch Changes

  • Updated dependencies [b0ad4f0c, 302bdba1]:
    • babel-plugin-emotion@11.0.0-next.0
    • @emotion/core@11.0.0-next.0
    • @emotion/styled-base@11.0.0-next.0

10.0.31

Patch Changes

  • ef7794f #1788 Thanks @aaronjensen! - Fixed issue with TypeScript 3.8 where theme was inferred to be required for a styled component.

10.0.30

Patch Changes

  • Updated dependencies [babbbe3]:
    • @emotion/is-prop-valid@0.8.8

10.0.28

Patch Changes

  • Updated dependencies [12141c5, d0b2a94]:
    • @emotion/is-prop-valid@0.8.7
    • @emotion/core@10.0.28

10.0.27

Patch Changes

  • 4c62ae9 #1698 Thanks @Andarist! - Add LICENSE file
  • Updated dependencies [4c62ae9]:
    • babel-plugin-emotion@10.0.27
    • @emotion/core@10.0.27
    • @emotion/styled-base@10.0.27

10.0.23

Patch Changes

10.0.22

Patch Changes

  • 57a767ea #1560 Thanks @Andarist! - Fix composition of styles without a final semicolon in a declaration block
  • c3f0bc10 #1545 Thanks @jgroszko! - Accept objects as className in styled components (they are stringified) to match React behavior

10.0.17

Patch Changes

10.0.15

Patch Changes

  • 8638c416 #1421 Thanks @Andarist! - TS: Disallow Theme parameter when it was already parametrized by using CustomStyled

10.0.14

Patch Changes

10.0.12

Patch Changes

10.0.11

Patch Changes