@compiled/react 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/package.json +2 -1
  2. package/src/css/__tests__/types.test.ts +11 -0
  3. package/dist/browser/class-names/index.js.flow +0 -53
  4. package/dist/browser/css/index.js.flow +0 -36
  5. package/dist/browser/css-map/index.js.flow +0 -125
  6. package/dist/browser/css-map/pseudos.js.flow +0 -57
  7. package/dist/browser/index.js.flow +0 -13
  8. package/dist/browser/keyframes/index.js.flow +0 -48
  9. package/dist/browser/runtime/ac.js.flow +0 -56
  10. package/dist/browser/runtime/ax.js.flow +0 -27
  11. package/dist/browser/runtime/cache.js.flow +0 -18
  12. package/dist/browser/runtime/css-custom-property.js.flow +0 -19
  13. package/dist/browser/runtime/dev-warnings.js.flow +0 -7
  14. package/dist/browser/runtime/index.js.flow +0 -11
  15. package/dist/browser/runtime/is-server-environment.js.flow +0 -19
  16. package/dist/browser/runtime/sheet.js.flow +0 -36
  17. package/dist/browser/runtime/style-cache.js.flow +0 -19
  18. package/dist/browser/runtime/style.js.flow +0 -16
  19. package/dist/browser/runtime/types.js.flow +0 -23
  20. package/dist/browser/runtime.js.flow +0 -7
  21. package/dist/browser/styled/index.js.flow +0 -66
  22. package/dist/browser/types.js.flow +0 -31
  23. package/dist/browser/utils/error.js.flow +0 -7
  24. package/dist/cjs/class-names/index.js.flow +0 -53
  25. package/dist/cjs/css/index.js.flow +0 -36
  26. package/dist/cjs/css-map/index.js.flow +0 -125
  27. package/dist/cjs/css-map/pseudos.js.flow +0 -57
  28. package/dist/cjs/index.js.flow +0 -13
  29. package/dist/cjs/keyframes/index.js.flow +0 -48
  30. package/dist/cjs/runtime/ac.js.flow +0 -56
  31. package/dist/cjs/runtime/ax.js.flow +0 -27
  32. package/dist/cjs/runtime/cache.js.flow +0 -18
  33. package/dist/cjs/runtime/css-custom-property.js.flow +0 -19
  34. package/dist/cjs/runtime/dev-warnings.js.flow +0 -7
  35. package/dist/cjs/runtime/index.js.flow +0 -11
  36. package/dist/cjs/runtime/is-server-environment.js.flow +0 -19
  37. package/dist/cjs/runtime/sheet.js.flow +0 -36
  38. package/dist/cjs/runtime/style-cache.js.flow +0 -19
  39. package/dist/cjs/runtime/style.js.flow +0 -16
  40. package/dist/cjs/runtime/types.js.flow +0 -23
  41. package/dist/cjs/runtime.js.flow +0 -7
  42. package/dist/cjs/styled/index.js.flow +0 -66
  43. package/dist/cjs/types.js.flow +0 -31
  44. package/dist/cjs/utils/error.js.flow +0 -7
  45. package/dist/esm/class-names/index.js.flow +0 -53
  46. package/dist/esm/css/index.js.flow +0 -36
  47. package/dist/esm/css-map/index.js.flow +0 -125
  48. package/dist/esm/css-map/pseudos.js.flow +0 -57
  49. package/dist/esm/index.js.flow +0 -13
  50. package/dist/esm/keyframes/index.js.flow +0 -48
  51. package/dist/esm/runtime/ac.js.flow +0 -56
  52. package/dist/esm/runtime/ax.js.flow +0 -27
  53. package/dist/esm/runtime/cache.js.flow +0 -18
  54. package/dist/esm/runtime/css-custom-property.js.flow +0 -19
  55. package/dist/esm/runtime/dev-warnings.js.flow +0 -7
  56. package/dist/esm/runtime/index.js.flow +0 -11
  57. package/dist/esm/runtime/is-server-environment.js.flow +0 -19
  58. package/dist/esm/runtime/sheet.js.flow +0 -36
  59. package/dist/esm/runtime/style-cache.js.flow +0 -19
  60. package/dist/esm/runtime/style.js.flow +0 -16
  61. package/dist/esm/runtime/types.js.flow +0 -23
  62. package/dist/esm/runtime.js.flow +0 -7
  63. package/dist/esm/styled/index.js.flow +0 -66
  64. package/dist/esm/types.js.flow +0 -31
  65. package/dist/esm/utils/error.js.flow +0 -7
  66. package/src/class-names/__tests__/types.test.js.flow +0 -35
  67. package/src/class-names/index.js.flow +0 -53
  68. package/src/css/__tests__/types.test.js.flow +0 -42
  69. package/src/css/index.js.flow +0 -36
  70. package/src/css-map/index.js.flow +0 -125
  71. package/src/css-map/pseudos.js.flow +0 -57
  72. package/src/index.js.flow +0 -13
  73. package/src/keyframes/__tests__/types.test.js.flow +0 -31
  74. package/src/keyframes/index.js.flow +0 -48
  75. package/src/runtime/ac.js.flow +0 -56
  76. package/src/runtime/ax.js.flow +0 -27
  77. package/src/runtime/cache.js.flow +0 -18
  78. package/src/runtime/css-custom-property.js.flow +0 -19
  79. package/src/runtime/dev-warnings.js.flow +0 -7
  80. package/src/runtime/index.js.flow +0 -11
  81. package/src/runtime/is-server-environment.js.flow +0 -19
  82. package/src/runtime/sheet.js.flow +0 -36
  83. package/src/runtime/style-cache.js.flow +0 -19
  84. package/src/runtime/style.js.flow +0 -16
  85. package/src/runtime/types.js.flow +0 -23
  86. package/src/runtime.js.flow +0 -7
  87. package/src/styled/__tests__/types.test.js.flow +0 -84
  88. package/src/styled/index.js.flow +0 -66
  89. package/src/types.js.flow +0 -31
  90. package/src/utils/error.js.flow +0 -7
@@ -1,27 +0,0 @@
1
- /**
2
- * Flowtype definitions for ax
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- /**
8
- * Joins classes together and ensures atomic declarations of a single group exist.
9
- * Atomic declarations take the form of `_{group}{value}` (always prefixed with an underscore),
10
- * where both `group` and `value` are hashes **four characters long**.
11
- * Class names can be of any length,
12
- * this function can take both atomic declarations and class names.
13
- *
14
- * Input:
15
- *
16
- * ```
17
- * ax(['_aaaabbbb', '_aaaacccc'])
18
- * ```
19
- *
20
- * Output:
21
- *
22
- * ```
23
- * '_aaaacccc'
24
- * ```
25
- * @param classes
26
- */
27
- declare export default function ax(classNames: (string | void | false)[]): string | void;
@@ -1,18 +0,0 @@
1
- /**
2
- * Flowtype definitions for cache
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- /**
8
- * Returns `true` when caching should be disabled, else `false`.
9
- *
10
- * Any code within this check will be removed in the output bundles:
11
- *
12
- * ```js
13
- * if (isCacheDisabled()) {
14
- * // This code will be removed from the output bundles
15
- * }
16
- * ```
17
- */
18
- declare export var isCacheDisabled: () => boolean;
@@ -1,19 +0,0 @@
1
- /**
2
- * Flowtype definitions for css-custom-property
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- /**
8
- * Returns a CSS custom property value with an optional suffix & prefix.
9
- * Prefix will only be added if there is a suffix.
10
- * If the value is undefined a fallback value will be returned to prevent children inheriting parent values.
11
- * @param value
12
- * @param suffix
13
- * @param prefix
14
- */
15
- declare export default function cssCustomPropertyValue(
16
- value: string | number | null | void,
17
- suffix?: string | void | null,
18
- prefix?: string | void | null
19
- ): string | number;
@@ -1,7 +0,0 @@
1
- /**
2
- * Flowtype definitions for dev-warnings
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- declare export var analyzeCssInDev: (sheet: string) => void;
@@ -1,11 +0,0 @@
1
- /**
2
- * Flowtype definitions for index
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- declare export { default as CS } from './style';
8
- declare export { default as CC } from './style-cache';
9
- declare export { default as ax } from './ax';
10
- declare export { default as ac, clearCache as clearAcCache } from './ac';
11
- declare export { default as ix } from './css-custom-property';
@@ -1,19 +0,0 @@
1
- /**
2
- * Flowtype definitions for is-server-environment
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- /**
8
- * Returns `true` when inside a node environment,
9
- * else `false`.
10
- *
11
- * When using this it will remove any node code from the browser bundle - for example:
12
- *
13
- * ```js
14
- * if (isServerEnvironment()) {
15
- * // This code will be removed from the browser bundle
16
- * }
17
- * ```
18
- */
19
- declare export var isServerEnvironment: () => boolean;
@@ -1,36 +0,0 @@
1
- /**
2
- * Flowtype definitions for sheet
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import type { Bucket, StyleSheetOpts } from './types';
8
- /**
9
- * Ordered style buckets using their short psuedo name.
10
- * If changes are needed make sure that it aligns with the definition in `sort-at-rule-pseudos.tsx`.
11
- */
12
- declare export var styleBucketOrdering: Bucket[];
13
- /**
14
- * Gets the bucket depending on the sheet.
15
- * This function makes assumptions as to the form of the input class name.
16
- *
17
- * Input:
18
- *
19
- * ```
20
- * "._a1234567:hover{ color: red; }"
21
- * ```
22
- *
23
- * Output:
24
- *
25
- * ```
26
- * "h"
27
- * ```
28
- * @param sheet styles for which we are getting the bucket
29
- */
30
- declare export var getStyleBucketName: (sheet: string) => Bucket;
31
- /**
32
- * Used to move styles to the head of the application during runtime.
33
- * @param css string
34
- * @param opts StyleSheetOpts
35
- */
36
- declare export default function insertRule(css: string, opts: StyleSheetOpts): void;
@@ -1,19 +0,0 @@
1
- /**
2
- * Flowtype definitions for style-cache
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import type { ProviderComponent, UseCacheHook } from './types';
8
- /**
9
- * Hook using the cache created on the server or client.
10
- */
11
- declare export var useCache: UseCacheHook;
12
- /**
13
- * On the server this ensures the minimal amount of styles will be rendered
14
- * safely using React Context.
15
- *
16
- * On the browser this turns into a fragment with no React Context.
17
- */
18
- declare var StyleCacheProvider: ProviderComponent;
19
- declare export default typeof StyleCacheProvider;
@@ -1,16 +0,0 @@
1
- /**
2
- * Flowtype definitions for style
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import type { StyleSheetOpts } from './types';
8
- declare type StyleProps = {
9
- /**
10
- * CSS Rules.
11
- * Ensure each rule is a separate element in the array.
12
- */
13
- children: string[],
14
- ...
15
- } & StyleSheetOpts;
16
- declare export default function Style(props: StyleProps): React$Node | null;
@@ -1,23 +0,0 @@
1
- /**
2
- * Flowtype definitions for types
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- export interface StyleSheetOpts {
8
- /**
9
- * Used to set a nonce on the style element.
10
- * This is needed when using a strict CSP and should be a random hash generated every server load.
11
- * Check out https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src for more information.
12
- */
13
- nonce?: string;
14
- }
15
- /**
16
- * Buckets under which we will group our stylesheets
17
- */
18
- export type Bucket = '' | 'l' | 'v' | 'w' | 'f' | 'i' | 'h' | 'a' | 'm';
19
- export type UseCacheHook = () => { [key: string]: true };
20
- export type ProviderComponent = (props: {
21
- children: React$Node[] | React$Node,
22
- ...
23
- }) => React$Node;
@@ -1,7 +0,0 @@
1
- /**
2
- * Flowtype definitions for runtime
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- declare export { CC, CS, ax, ac, clearAcCache, ix } from './runtime/index';
@@ -1,84 +0,0 @@
1
- // @flow strict-local
2
- import React, { type Node, type Element } from 'react';
3
- import { styled, type CssType } from '@compiled/react';
4
-
5
- // Tagged template expression
6
- () => {
7
- const StyledComponent = styled.div`
8
- font-size: 12px;
9
- `;
10
- return <StyledComponent>red text</StyledComponent>;
11
- };
12
-
13
- // Tagged template expression with conditional
14
- () => {
15
- const StyledComponent = styled.div`
16
- font-size: ${({ big }) => (big ? big : 12)}px;
17
- `;
18
- return <StyledComponent big>red text</StyledComponent>;
19
- };
20
-
21
- // Object call expression
22
- () => {
23
- const StyledComponent = styled.div<{ big: number, children: Node }>({
24
- fontSize: (props: { big: number, children: Node }): number => (props.big == 5 ? 50 : 10),
25
- });
26
-
27
- return <StyledComponent big={5}>red text</StyledComponent>;
28
- };
29
-
30
- // Object call expression with no props
31
- () => {
32
- const StyledComponent = styled.div({
33
- wordBreak: 'break-word',
34
- position: 'relative',
35
- left: `${2 - 2}px`,
36
- });
37
-
38
- return <StyledComponent>red text</StyledComponent>;
39
- };
40
-
41
- // Object call expression with conditional
42
- () => {
43
- const StyledComponent = styled.div<{ big: number, children: Node }>({
44
- fontSize: ({ big }) => `${big ? 50 : 12}px`,
45
- width: ({ big }) => (big ? 500 : 120),
46
- });
47
-
48
- return <StyledComponent big={5}>red text</StyledComponent>;
49
- };
50
-
51
- // Object call expression with logical operator expression
52
- () => {
53
- // Type defined as constant so we test the type without sketchy null check errors
54
- const StyledComponent = styled.div<{ big?: 5000, children: Node }>(
55
- {
56
- fontSize: ({ big }) => `${big || 50}px`,
57
- width: ({ big }) => big && 500,
58
- },
59
- ({ big }) => big && { height: '100px' }
60
- );
61
-
62
- return <StyledComponent big={5000}>red text</StyledComponent>;
63
- };
64
-
65
- // Array
66
- () => {
67
- const styles: CssType<{ fontSize: number, children: Node }>[] = [{ fontSize: '12px' }];
68
- const StyledComponent = styled.div(styles);
69
- return <StyledComponent fontSize={50}>red text</StyledComponent>;
70
- };
71
-
72
- // Multiple arguments
73
- () => {
74
- const StyledComponent = styled.div({ fontSize: 12 }, `font-size: 12px`);
75
- return <StyledComponent>red text</StyledComponent>;
76
- };
77
-
78
- // Dynamic function calls
79
- () => {
80
- const StyledComponent = styled.div({
81
- backgroundColor: token('elevation.surface', 'black'),
82
- zIndex: layers.modal(),
83
- });
84
- };
@@ -1,66 +0,0 @@
1
- /**
2
- * Flowtype definitions for index
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import type { ComponentType } from 'react';
8
- import type { CssType, CssFunction } from '../types';
9
- /**
10
- * Extra props added to the output Styled Component.
11
- */
12
- export type StyledProps = {
13
- as?: $Keys<$JSXIntrinsics>,
14
- };
15
- export type ObjectInterpolation<TProps> = CssType<TProps> | CssType<TProps>[];
16
- export type TemplateStringsInterpolation<TProps> = CssFunction<TProps> | CssFunction<TProps>[];
17
- export interface StyledComponent<ComponentProps> {
18
- <TProps>(
19
- ...css: ObjectInterpolation<TProps>[]
20
- ): React$ComponentType<{ ...TProps, ...ComponentProps, ...StyledProps }>;
21
- <TProps>(
22
- template: $ReadOnlyArray<string>,
23
- ...interpolations: TemplateStringsInterpolation<TProps>[]
24
- ): React$ComponentType<{ ...TProps, ...ComponentProps, ...StyledProps }>;
25
- }
26
- export type StyledComponentMap = $ObjMapi<$JSXIntrinsics, <Tag>(Tag) => StyledComponent<mixed>>;
27
- export type CreateStyledComponent = {
28
- <TInheritedProps>(Component: ComponentType<TInheritedProps>): StyledComponent<TInheritedProps>,
29
- ...
30
- } & StyledComponentMap;
31
- /**
32
- * ## Styled component
33
- *
34
- * Create a component that styles a JSX element which comes with built-in behavior such as `ref` and `as` prop support.
35
- * For further details [read the documentation](https://compiledcssinjs.com/docs/api-styled).
36
- *
37
- * ### Style with objects
38
- * @example ```
39
- * styled.div({
40
- * fontSize: 12,
41
- * });
42
- * ```
43
- *
44
- * ### Style with template literals
45
- * @example ```
46
- * styled.div`
47
- * font-size: 12px
48
- * `;
49
- * ```
50
- *
51
- * ### Compose styles with arrays
52
- * @example ```
53
- * import type { css } from '@compiled/react';
54
- *
55
- * styled.div([
56
- * { fontSize: 12 },
57
- * css`font-size: 12px;`
58
- * ]);
59
- *
60
- * styled.div(
61
- * { fontSize: 12 },
62
- * css`font-size: 12px`
63
- * );
64
- * ```
65
- */
66
- declare export var styled: CreateStyledComponent;
package/src/types.js.flow DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * Flowtype definitions for types
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as CSS from 'csstype';
8
- /**
9
- * Typing for the interpolations.
10
- */
11
- export type BasicTemplateInterpolations = string | number;
12
- export interface FunctionInterpolation<TProps> {
13
- (props: TProps): CssFunction<TProps>;
14
- }
15
- /**
16
- * Possible types for a CSS value
17
- */
18
- export type CssType<TProps> = CssObject<TProps> | FunctionInterpolation<TProps> | string;
19
- /**
20
- * These are all the CSS props that will exist.
21
- */
22
- export type CSSProps<TProps> = $ReadOnly<CSS.Properties<CssFunction<TProps>>>;
23
- export type CssObject<TProps> = $ReadOnly<{
24
- ...CSSProps<TProps>,
25
- [key: string]: CssFunction<TProps>,
26
- }>;
27
- export type CssFunction<TProps = mixed> =
28
- | CssType<TProps>
29
- | BasicTemplateInterpolations
30
- | boolean
31
- | void;
@@ -1,7 +0,0 @@
1
- /**
2
- * Flowtype definitions for error
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- declare export var createSetupError: () => Error;