@atlaskit/primitives 1.0.8 → 1.0.10

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 1.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ac645224013`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ac645224013) - Removes generic for `xcss` fn. Adds support for other `AtTypes`.
8
+
9
+ ## 1.0.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [`1859bc0b8c7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1859bc0b8c7) - Update the casing on `xcss` to ensure consistency with the API and package consumption.
14
+
3
15
  ## 1.0.8
4
16
 
5
17
  ### Patch Changes
@@ -96,7 +108,7 @@
96
108
 
97
109
  ### Patch Changes
98
110
 
99
- - [`4c026f170d6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4c026f170d6) - Remove warnings for non-token values passed to xCSS in non-development environments.
111
+ - [`4c026f170d6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4c026f170d6) - Remove warnings for non-token values passed to xcss in non-development environments.
100
112
 
101
113
  ## 0.14.2
102
114
 
@@ -173,7 +185,7 @@
173
185
 
174
186
  ### Minor Changes
175
187
 
176
- - [`8bd6dc6027f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8bd6dc6027f) - Box backgroundColor prop now accepts full token names, abbreviated forms will no longer work. xCSS now accepts full token names, abbreviated forms will no longer work.
188
+ - [`8bd6dc6027f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8bd6dc6027f) - Box backgroundColor prop now accepts full token names, abbreviated forms will no longer work. xcss now accepts full token names, abbreviated forms will no longer work.
177
189
 
178
190
  ## 0.10.1
179
191
 
@@ -186,7 +198,7 @@
186
198
 
187
199
  ### Minor Changes
188
200
 
189
- - [`313d71fce9c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/313d71fce9c) - Allow media queries at predefined breakpoints to be applied through xCSS.
201
+ - [`313d71fce9c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/313d71fce9c) - Allow media queries at predefined breakpoints to be applied through xcss.
190
202
 
191
203
  ## 0.9.5
192
204
 
package/README.md CHANGED
@@ -10,4 +10,4 @@ Detailed docs and example usage can be found at:
10
10
  - [Box](https://staging.atlassian.design/components/primitives/box)
11
11
  - [Inline](https://staging.atlassian.design/components/primitives/inline)
12
12
  - [Stack](https://staging.atlassian.design/components/primitives/stack)
13
- - [xCSS](https://staging.atlassian.design/components/primitives/xcss)
13
+ - [xcss](https://staging.atlassian.design/components/primitives/xcss)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Box
3
- description: Box is a primitive component that leverages the foundations of the Atlassian Design System.
3
+ description: A box is a primitive component that acts as a generic container, and provides managed access to design tokens.
4
4
  order: 1
5
5
  ---
6
6
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Box
3
- description: Box is a primitive component that leverages the foundations of the Atlassian Design System.
3
+ description: A box is a primitive component that acts as a generic container, and provides managed access to design tokens.
4
4
  order: 0
5
5
  ---
6
6
 
@@ -20,32 +20,33 @@ import { CodeDocsHeader } from '@af/design-system-docs-ui';
20
20
 
21
21
  ## Basic
22
22
 
23
- Box is a general-purpose container with controlled use of design tokens. Use the given props to configure display behaviour using scalable recommendations from the Atlassian Design System.
23
+ Box is a general-purpose container that allows for controlled use of design tokens. Use the given props to configure display behaviour and styling that aligns with the Atlassian Design System.
24
+ [To learn more about styling primitive components visit our xcss documentation.](/components/primitives/xcss/usage)
24
25
 
25
26
  <Example Component={BoxBasic} packageName="@atlaskit/primitives/box" />
26
27
 
27
28
  ## Padding
28
29
 
29
- Padding props can be used to access spacing design token and control internal layout. The following example demonstrates how each prop works individually:
30
+ Padding props can be used to access spacing design tokens and control internal layout. The following example demonstrates how each prop works with space tokens.
30
31
 
31
32
  <Example Component={BoxPadding} packageName="@atlaskit/primitives/box" />
32
33
 
33
- *Note*: The nomenclature used by these props follows [logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties). It might be less intuitive at first but they are adequate to properly support different [writing modes](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode) in our products.
34
+ The nomenclature used by these props follows [logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties). This naming is used to support different [writing modes](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode) in our products.
34
35
 
35
36
  ## Background color
36
37
 
37
- `Box` accepts a wide variety of background colors, referenced as semantic design tokens.
38
+ `Box` accepts a wide variety of background colors, referenced as semantic design tokens. For the full list of color tokens or to learn more, visit our [Token documentation](/tokens/design-tokens/).
38
39
 
39
40
  <Example Component={BoxBackgroundColor} packageName="@atlaskit/primitives/box" />
40
41
 
41
- ## xCSS
42
+ ## xcss
42
43
 
43
- Box also exposes an `xcss` prop. This prop can take `xcss` function calls that contain a subset of permitted styles. When used with `Box`, xCSS takes most CSS properties, and when a token exists, the rule accepts that token as a value.
44
+ Box exposes an `xcss` prop. This prop accepts `xcss` function calls that contain a subset of permitted styles. When used with `Box`, xcss accepts most CSS properties, and when a token exists, the rule accepts that token as a value.
45
+ For more information on xcss, see the dedicated [xcss documentation](/components/primitives/xcss).
44
46
 
45
47
  <Example Component={BoxXcss} packageName="@atlaskit/primitives/box" />
46
48
 
47
- For more information on xCSS, see the dedicated [xCSS](/components/primitives/xcss) documentation.
48
-
49
- ## Practical Use Case
49
+ ## Practical use case
50
50
 
51
+ `Box` is designed to be used in conjunction with `Inline` and `Stack` to create layouts. This example demonstrates how primitives can be used to create familiar components and patterns.
51
52
  <Example Component={PracticalUseCase} packageName="@atlaskit/primitives/box" />
@@ -4,12 +4,10 @@ description: A box is a primitive component that acts as a generic container, an
4
4
  order: 2
5
5
  ---
6
6
 
7
- Use box to compose layouts with the valid spacing and background colors. A `Box` is a generic container with convenient and managed access to design tokens, and built-in guidance for the best practices of the Atlassian Design System.
7
+ A `Box` is a generic container with convenient and managed access to design tokens, and built-in guidance for the best practices of the Atlassian Design System.
8
+ Use a `Box` to compose layouts and add styling to child elements through visual props, including spacing and color through design tokens.
8
9
 
9
- A `Box` is primarily a containment element, with visual props that affect the whitespace available to child elements.
10
-
11
-
12
- ## Use `Box`
10
+ ## `Box` styling
13
11
  Display behavior is set by using the available props or using `xcss`. Makers can make design decisions for `Box` by setting:
14
12
 
15
13
  - `padding`
@@ -21,10 +19,13 @@ Display behavior is set by using the available props or using `xcss`. Makers can
21
19
  - `paddingBlockEnd`
22
20
  - `backgroundColor`
23
21
 
24
- To identify usages of `Box` in a given design, look for where a UI element (could be as small as the parent of a button or as a big as the wrapper of an entire section) will receive some visual styles applied to a container.
25
-
22
+ ## Using `Box`
23
+ To identify usages of `Box` in a given design, look for where a UI element will receive some visual styles applied to a container. `Box` can be used on a range of sizes of elements, from buttons to section wrappers.
26
24
  `Box`, being generic in nature, can be "over-used", so it’s important to consider situations where more specific and expressive primitives could be used, for example: `Inline` and `Stack` to manage horizontal and vertical layouts, respectively.
27
25
 
28
- Related
26
+ ## Related
29
27
  - [Learn more about the Inline primitive](/components/primitives/inline/usage)
30
28
  - [Learn more about the Stack primitive](/components/primitives/stack/usage)
29
+ - [Learn more about the Grid primitive](/components/primitives/grid/examples)
30
+ - [Learn more about the Bleed primitive](/components/primitives/bleed/examples)
31
+ - [Learn more about the Flex primitive](/components/primitives/flex/examples)
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  title: Inline
3
- description: An Inline is a primitive component that is responsible for the horizontal layout of its child elements.
3
+ description: Inline is a primitive component based on flexbox that manages the horizontal layout of direct children.
4
4
  order: 2
5
5
  ---
6
6
 
7
- Primitive components are designed to act as building blocks for composing a user experience. An Inline primitive should be used when you want to layout UI elements horizontally, and make use of the built-in design guidance from the Atlassian Design System.
7
+ Primitive components are designed to act as building blocks for composing a user experience. An Inline primitive should be used when you want to layout UI elements horizontally, and make use of the built-in design guidance from the Atlassian Design System.
8
8
 
9
- Inline primitives work as you might expect, aligning content horizontally across a page or layout, as a container that decides the horizontal layout of its children. Inline components also decide the specifics of how the children are displayed, for example, where they are aligned or how much space is between child elements. Inline should be used purely for visual alignment, and should have no opinions about the functionality of its children.
9
+ Inline primitives work as you might expect, aligning content horizontally across a page or layout, as a container that decides the horizontal layout of its children. Inline components also decide the specifics of how the children are displayed, for example, where they are aligned or how much space is between child elements. Inline should be used purely for visual alignment, and should have no opinions about the functionality of its children.
10
10
 
11
11
  In its simplest form, `Inline` operates like a flexbox row, however adds the built in design token support and guidance.
12
12
 
@@ -18,7 +18,7 @@ In its simplest form, `Inline` operates like a flexbox row, however adds the bui
18
18
  It also has a flex-direction: row; but that’s the default, so not explicitly applied.
19
19
 
20
20
  ## Use `Inline`
21
- The purpose of an Inline is primarily as a container element controlling how child components are displayed and positioned horizontally. Inline should be used any time you wish to layout elements or components horizontally.
21
+ The purpose of an Inline is primarily as a container element controlling how child components are displayed and positioned horizontally. Inline should be used any time you wish to layout elements or components horizontally.
22
22
 
23
23
  The various Inline props can then be used to customize the spacing and styling on any child elements. These include:
24
24
 
@@ -31,6 +31,9 @@ The various Inline props can then be used to customize the spacing and styling o
31
31
  - `rowSpace`
32
32
  - `separator`
33
33
 
34
- ## Related
35
34
  - [Learn more about the Box primitive](/components/primitives/box/usage)
36
35
  - [Learn more about the Stack primitive](/components/primitives/stack/usage)
36
+ - [Learn more about the Grid primitive](/components/primitives/grid/examples)
37
+ - [Learn more about the Bleed primitive](/components/primitives/bleed/examples)
38
+ - [Learn more about the Flex primitive](/components/primitives/flex/examples)
39
+
@@ -23,9 +23,8 @@ Primitives are a new type of component for layouts and the placement of elements
23
23
  They act as simple building blocks to compose different parts of the user experience,
24
24
  from the smallest design decisions (for example, the spacing around an icon) to larger layout decisions (for example, how a page is structured).
25
25
 
26
- Primitives are a combination of design tokens that go a step further.
27
- These are component-like abstractions powered by design tokens that add a layer of ergonomics and accessibility. Tokens are great at describing the what of a design decision;
28
- primitives make it easier to reason about the when and how. This reduces cognitive overhead and prevents accidents or mistakes.
26
+ Primitives are powered by design tokens and add a layer of ergonomics and accessibility to token application. Tokens are great at describing the what of a design decision;
27
+ primitives make it easier to reason about the when and how. This reduces cognitive overhead, improves productivity and prevents accidents or mistakes.
29
28
 
30
29
  ## Available Primitives
31
30
 
@@ -57,14 +56,14 @@ This involves breaking down a design into its core layout components to as granu
57
56
 
58
57
  You might like to think first about breaking down a page into `Box` containers,
59
58
  identifying larger pieces of a design that function in a similar manner or fulfill a singular purpose
60
- in a layout and grouping them together under a Box.
59
+ in a layout and grouping them together under a `Box`.
61
60
 
62
61
  <Image src={boxUsageExample} />
63
62
 
64
63
  The behavior within and around these boxes can then be broken down into their horizontal `Inline` and vertical `Stack` components.
65
64
 
66
65
  <SectionMessage>
67
- The ESLint rule use-primitives offers suggestions for possible primitives in a layout.
66
+ The ESLint rule <a href="/components/eslint-plugin-design-system/usage#use-primitives">use-primitives</a> offers suggestions for possible primitives to apply in a layout.
68
67
  </SectionMessage>
69
68
 
70
69
  <Image src={inlineUsageExample} />
@@ -75,3 +74,6 @@ The ESLint rule use-primitives offers suggestions for possible primitives in a l
75
74
  - [Learn more about the Box primitive](/components/primitives/box/usage)
76
75
  - [Learn more about the Inline primitive](/components/primitives/inline/usage)
77
76
  - [Learn more about the Stack primitive](/components/primitives/stack/usage)
77
+ - [Learn more about the Grid primitive](/components/primitives/grid/examples)
78
+ - [Learn more about the Bleed primitive](/components/primitives/bleed/examples)
79
+ - [Learn more about the Fkex primitive](/components/primitives/flex/examples)
@@ -19,33 +19,3 @@ Media queries can be applied through the `media` object.
19
19
 
20
20
 
21
21
  <MediaQueriesTable />
22
-
23
- When used with `xcss`, be aware that a media query can't contain another media query to prevent arbitrary nesting. Additionally, pseudo-selectors can't contain media queries. To use media queries and pseudos, the media query must contain the pseudo.
24
-
25
- ```
26
- import { xcss } from '@atlaskit/primitives';
27
- import { media } from '@atlaskit/primitives/responsive';
28
-
29
- const someStyles = xcss({
30
- // This is okay, since media queries can contain pseudos
31
- [media.above.md]: {
32
- ':hover': {
33
- backgroundColor: 'color.background.primary.hovered'
34
- }
35
- },
36
-
37
- // This is not okay, since pseudos can't contain media queries
38
- ':hover': {
39
- [media.above.md]: {
40
- backgroundColor: 'color.background.primary.hovered'
41
- }
42
- },
43
-
44
- // This is not okay, since media queries can't contain media queries
45
- [media.above.md]: {
46
- [media.above.xs]: {
47
- backgroundColor: 'color.background.primary.hovered'
48
- }
49
- },
50
- });
51
- ```
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  title: Stack
3
- description: A Stack is a primitive component that is responsible for the vertical layout of its child elements.
3
+ description: Stack is a primitive component based on flexbox that manages the vertical layout of direct children.
4
4
  order: 2
5
5
  ---
6
6
 
7
- Primitive components are designed to act as building blocks for composing a user experience. A `Stack` primitive should be used when you want to layout UI elements vertically, and make use of the built-in design guidance from the Atlassian Design System.
7
+ Primitive components are designed to act as building blocks for composing a user experience. A `Stack` primitive should be used when you want to layout UI elements vertically, and make use of the built-in design guidance from the Atlassian Design System.
8
8
 
9
- `Stack` primitives work by aligning content vertically on a page or layout, as a container that decides the vertical layout of its children. `Stack` components also decide the specifics of how the children are displayed, for example, where they are aligned or how much space is between child elements. `Stack` should be used purely for visual alignment, and should have no opinions about the functionality of its children.
9
+ `Stack` primitives work by aligning content vertically on a page or layout, as a container that decides the vertical layout of its children. `Stack` components also decide the specifics of how the children are displayed, for example, where they are aligned or how much space is between child elements. `Stack` should be used purely for visual alignment, and should have no opinions about the functionality of its children.
10
10
 
11
11
  In its simplest form, `Stack` operates like a flexbox column, however adds the built in design token support and guidance.
12
12
 
@@ -17,7 +17,7 @@ In its simplest form, `Stack` operates like a flexbox column, however adds the b
17
17
  ```
18
18
 
19
19
  ## Use `Stack`
20
- The purpose of a `Stack` is primarily as a container element controlling how content is displayed and aligned vertically. `Stack` should be used any time you wish to layout elements or components vertically.
20
+ The purpose of a `Stack` is primarily as a container element controlling how content is displayed and aligned vertically. `Stack` should be used any time you wish to layout elements or components vertically.
21
21
 
22
22
  The various `Stack` props can then be used to customize the spacing and styling on any child elements. These include:
23
23
  - `alignBlock`
@@ -27,5 +27,9 @@ The various `Stack` props can then be used to customize the spacing and styling
27
27
  - `space`
28
28
 
29
29
  ## Related
30
- - [Learn more about the Box primitive](/primitives/box/usage)
31
- - [Learn more about the Stack primitive](/primitives/box/usage)
30
+
31
+ - [Learn more about the Box primitive](/components/primitives/box/usage)
32
+ - [Learn more about the Inline primitive](/components/primitives/inline/usage)
33
+ - [Learn more about the Grid primitive](/components/primitives/grid/examples)
34
+ - [Learn more about the Bleed primitive](/components/primitives/bleed/examples)
35
+ - [Learn more about the Flex primitive](/components/primitives/flex/examples)
@@ -1,6 +1,6 @@
1
1
  ---
2
- title: xCSS
3
- description: xCSS is a safer, tokens-first approach to CSS-in-JS.
2
+ title: xcss
3
+ description: xcss is a safer, tokens-first approach to CSS-in-JS.
4
4
  order: 1
5
5
  ---
6
6
 
@@ -31,6 +31,6 @@ To enable interactivity, use familiar selectors like `:hover` and `:focus-visibl
31
31
 
32
32
  ## Responsiveness
33
33
 
34
- xCSS also accepts a subset of media queries at predefined breakpoints:
34
+ xcss also accepts a subset of media queries at predefined breakpoints:
35
35
 
36
36
  <Example Component={xcssResponsive} packageName="@atlaskit/primitives/xcss" />
@@ -1,6 +1,6 @@
1
1
  ---
2
- title: Migrating your app to xCSS
3
- description: xCSS is a safer, tokens-first approach to CSS-in-JS.
2
+ title: Migrating your app to xcss
3
+ description: xcss is a safer, tokens-first approach to CSS-in-JS.
4
4
  order: 2
5
5
  ---
6
6
 
@@ -1,6 +1,6 @@
1
1
  ---
2
- title: xCSS
3
- description: xCSS is a safer, tokens-first approach to CSS-in-JS.
2
+ title: xcss
3
+ description: xcss is a safer, tokens-first approach to CSS-in-JS.
4
4
  order: 0
5
5
  ---
6
6
  import { MediaQueriesTable } from '@af/design-system-docs-ui';
@@ -55,7 +55,7 @@ Note: styles generated from `xcss` cannot be applied directly to the `className`
55
55
 
56
56
  ### Type safety
57
57
 
58
- `xcss` uses strongly-typed values generated from design token definitions, making it simpler to apply the right token to the right CSS property.
58
+ `xcss` uses strongly-typed values generated from design token definitions, making it simpler to apply the right token to the right CSS property.
59
59
  This is intended to be more ergonomic and intuitive, but also prevent the misapplication of tokens to the wrong properties.
60
60
 
61
61
  Any [valid token name](/components/tokens/all-tokens) is available to be applied against its
@@ -74,7 +74,7 @@ const someStyles = xcss({
74
74
  ```
75
75
 
76
76
  ### Restricted nesting
77
- `xcss` is flexible enough to implement any design, but it does restrict the application of styles in one key way.
77
+ `xcss` is flexible enough to implement any design, but it does restrict the application of styles in one key way.
78
78
  Selectors cannot be nested or target elements beyond the element on which styles are applied.
79
79
  This restriction is intended to encourage better component encapsulation, reduce side-effects and make the codebase more resilient to change.
80
80
 
@@ -108,14 +108,15 @@ These unsafe selectors will throw a type error if applied.
108
108
  For richer examples of how to use `xcss` please see the [primitives `xcss` documentation](/components/primitives/xcss/examples).
109
109
 
110
110
  ### Media Queries
111
- xCSS can create responsive layouts at predefined breakpoints that are consistent with the Atlassian Design System. To enable responsive behavior, xCSS exposes the following pre-defined breakpoints:
111
+ xcss can create responsive layouts at predefined breakpoints that are consistent with the Atlassian Design System. To enable responsive behavior, xcss exposes the following pre-defined breakpoints:
112
+
112
113
  <MediaQueriesTable />
113
114
 
114
115
  Media queries can be applied through keys that can be imported from `@atlaskit/primitives/responsive`.
115
116
  For in depth examples on how to enable responsive behavior, please see our [primitive responsiveness documentation](/components/primitives/xcss/examples#responsiveness).
116
117
 
117
- The objects defined at each breakpoint behave in much the same way as a normal xCSS object, and can apply responsiveness to any CSS.
118
- The only limitation is that a media query can't contain another media query. This is to prevent arbitrary nesting.
118
+ The objects defined at each breakpoint behave in much the same way as a normal xcss object, and can apply responsiveness to any CSS.
119
+ The only limitation is that a media query can't contain another media query. This is to prevent arbitrary nesting.
119
120
  Additionally, pseudo-selectors can't contain media queries. To use media queries and pseudos, the media query must contain the pseudo.
120
121
 
121
122
  ```
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "sideEffects": false
5
5
  }
@@ -10,7 +10,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
12
  var _react = require("@emotion/react");
13
- var _mediaHelper = require("../responsive/media-helper");
14
13
  var _styleMaps = require("./style-maps.partial");
15
14
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
16
15
 
@@ -75,16 +74,7 @@ var isSafeEnvToThrow = function isSafeEnvToThrow() {
75
74
  return (typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) === 'object' && (0, _typeof2.default)(process.env) === 'object' && process.env.NODE_ENV !== 'production';
76
75
  };
77
76
  var reNestedSelectors = /(\.|\s|&+|\*\>|#|\[.*\])/;
78
- var rePseudos = /^::?.*$/;
79
- var reMediaQuery = /^@media .*$/;
80
-
81
- /**
82
- * Reduce our media queries into a safe string for regex comparison.
83
- */
84
- var reValidMediaQuery = new RegExp("^(".concat(Object.values(_mediaHelper.media.above).map(function (mediaQuery) {
85
- return mediaQuery.replace(/[.()]/g, '\\$&');
86
- } // Escape the ".", "(", and ")" in the media query syntax.
87
- ).join('|'), ")$"));
77
+ var safeSelectors = /^@media .*$|^::?.*$|^@supports .*$/;
88
78
  var transformStyles = function transformStyles(styleObj) {
89
79
  if (!styleObj || (0, _typeof2.default)(styleObj) !== 'object') {
90
80
  return styleObj;
@@ -100,23 +90,17 @@ var transformStyles = function transformStyles(styleObj) {
100
90
  var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
101
91
  key = _ref2[0],
102
92
  value = _ref2[1];
103
- if (isSafeEnvToThrow()) {
104
- // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
105
- if (reNestedSelectors.test(key) && !reValidMediaQuery.test(key)) {
106
- throw new Error("Styles not supported for key '".concat(key, "'."));
107
- }
108
- }
109
-
110
93
  // If key is a pseudo class or a pseudo element, then value should be an object.
111
94
  // So, call transformStyles on the value
112
- if (rePseudos.test(key)) {
95
+ if ((0, _typeof2.default)(value) === 'object' && safeSelectors.test(key)) {
113
96
  styleObj[key] = transformStyles(value);
114
97
  return;
115
98
  }
116
- if (reMediaQuery.test(key)) {
117
- // @ts-expect-error
118
- styleObj[key] = transformStyles(value);
119
- return;
99
+ if (isSafeEnvToThrow()) {
100
+ // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
101
+ if (reNestedSelectors.test(key)) {
102
+ throw new Error("Styles not supported for key '".concat(key, "'."));
103
+ }
120
104
  }
121
105
 
122
106
  // We have now dealt with all the special cases, so,
@@ -157,13 +141,6 @@ var parseXcss = function parseXcss(args) {
157
141
 
158
142
  // Pseudos should not contain nested pseudos, or media queries
159
143
  exports.parseXcss = parseXcss;
160
- // unused private functions only so we can extract the return type from a generic function
161
- var boxWrapper = function boxWrapper(style) {
162
- return xcss(style);
163
- };
164
- var spaceWrapper = function spaceWrapper(style) {
165
- return xcss(style);
166
- };
167
144
  /**
168
145
  * ### xcss
169
146
  *
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
2
  import { css as cssEmotion } from '@emotion/react';
3
- import { media } from '../responsive/media-helper';
4
3
  import { backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
5
4
  const tokensMap = {
6
5
  backgroundColor: backgroundColorMap,
@@ -61,14 +60,7 @@ const tokensMap = {
61
60
  const uniqueSymbol = Symbol('UNSAFE_INTERNAL_styles');
62
61
  const isSafeEnvToThrow = () => typeof process === 'object' && typeof process.env === 'object' && process.env.NODE_ENV !== 'production';
63
62
  const reNestedSelectors = /(\.|\s|&+|\*\>|#|\[.*\])/;
64
- const rePseudos = /^::?.*$/;
65
- const reMediaQuery = /^@media .*$/;
66
-
67
- /**
68
- * Reduce our media queries into a safe string for regex comparison.
69
- */
70
- const reValidMediaQuery = new RegExp(`^(${Object.values(media.above).map(mediaQuery => mediaQuery.replace(/[.()]/g, '\\$&') // Escape the ".", "(", and ")" in the media query syntax.
71
- ).join('|')})$`);
63
+ const safeSelectors = /^@media .*$|^::?.*$|^@supports .*$/;
72
64
  const transformStyles = styleObj => {
73
65
  if (!styleObj || typeof styleObj !== 'object') {
74
66
  return styleObj;
@@ -81,23 +73,17 @@ const transformStyles = styleObj => {
81
73
 
82
74
  // Modifies styleObj in place. Be careful.
83
75
  Object.entries(styleObj).forEach(([key, value]) => {
84
- if (isSafeEnvToThrow()) {
85
- // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
86
- if (reNestedSelectors.test(key) && !reValidMediaQuery.test(key)) {
87
- throw new Error(`Styles not supported for key '${key}'.`);
88
- }
89
- }
90
-
91
76
  // If key is a pseudo class or a pseudo element, then value should be an object.
92
77
  // So, call transformStyles on the value
93
- if (rePseudos.test(key)) {
78
+ if (typeof value === 'object' && safeSelectors.test(key)) {
94
79
  styleObj[key] = transformStyles(value);
95
80
  return;
96
81
  }
97
- if (reMediaQuery.test(key)) {
98
- // @ts-expect-error
99
- styleObj[key] = transformStyles(value);
100
- return;
82
+ if (isSafeEnvToThrow()) {
83
+ // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
84
+ if (reNestedSelectors.test(key)) {
85
+ throw new Error(`Styles not supported for key '${key}'.`);
86
+ }
101
87
  }
102
88
 
103
89
  // We have now dealt with all the special cases, so,
@@ -140,9 +126,6 @@ export const parseXcss = args => {
140
126
 
141
127
  // Pseudos should not contain nested pseudos, or media queries
142
128
 
143
- // unused private functions only so we can extract the return type from a generic function
144
- const boxWrapper = style => xcss(style);
145
- const spaceWrapper = style => xcss(style);
146
129
  /**
147
130
  * ### xcss
148
131
  *
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _typeof from "@babel/runtime/helpers/typeof";
4
4
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
5
5
  import { css as cssEmotion } from '@emotion/react';
6
- import { media } from '../responsive/media-helper';
7
6
  import { backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
8
7
  var tokensMap = {
9
8
  backgroundColor: backgroundColorMap,
@@ -66,16 +65,7 @@ var isSafeEnvToThrow = function isSafeEnvToThrow() {
66
65
  return (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && _typeof(process.env) === 'object' && process.env.NODE_ENV !== 'production';
67
66
  };
68
67
  var reNestedSelectors = /(\.|\s|&+|\*\>|#|\[.*\])/;
69
- var rePseudos = /^::?.*$/;
70
- var reMediaQuery = /^@media .*$/;
71
-
72
- /**
73
- * Reduce our media queries into a safe string for regex comparison.
74
- */
75
- var reValidMediaQuery = new RegExp("^(".concat(Object.values(media.above).map(function (mediaQuery) {
76
- return mediaQuery.replace(/[.()]/g, '\\$&');
77
- } // Escape the ".", "(", and ")" in the media query syntax.
78
- ).join('|'), ")$"));
68
+ var safeSelectors = /^@media .*$|^::?.*$|^@supports .*$/;
79
69
  var transformStyles = function transformStyles(styleObj) {
80
70
  if (!styleObj || _typeof(styleObj) !== 'object') {
81
71
  return styleObj;
@@ -91,23 +81,17 @@ var transformStyles = function transformStyles(styleObj) {
91
81
  var _ref2 = _slicedToArray(_ref, 2),
92
82
  key = _ref2[0],
93
83
  value = _ref2[1];
94
- if (isSafeEnvToThrow()) {
95
- // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
96
- if (reNestedSelectors.test(key) && !reValidMediaQuery.test(key)) {
97
- throw new Error("Styles not supported for key '".concat(key, "'."));
98
- }
99
- }
100
-
101
84
  // If key is a pseudo class or a pseudo element, then value should be an object.
102
85
  // So, call transformStyles on the value
103
- if (rePseudos.test(key)) {
86
+ if (_typeof(value) === 'object' && safeSelectors.test(key)) {
104
87
  styleObj[key] = transformStyles(value);
105
88
  return;
106
89
  }
107
- if (reMediaQuery.test(key)) {
108
- // @ts-expect-error
109
- styleObj[key] = transformStyles(value);
110
- return;
90
+ if (isSafeEnvToThrow()) {
91
+ // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
92
+ if (reNestedSelectors.test(key)) {
93
+ throw new Error("Styles not supported for key '".concat(key, "'."));
94
+ }
111
95
  }
112
96
 
113
97
  // We have now dealt with all the special cases, so,
@@ -148,13 +132,6 @@ export var parseXcss = function parseXcss(args) {
148
132
 
149
133
  // Pseudos should not contain nested pseudos, or media queries
150
134
 
151
- // unused private functions only so we can extract the return type from a generic function
152
- var boxWrapper = function boxWrapper(style) {
153
- return xcss(style);
154
- };
155
- var spaceWrapper = function spaceWrapper(style) {
156
- return xcss(style);
157
- };
158
135
  /**
159
136
  * ### xcss
160
137
  *
@@ -133,5 +133,5 @@ declare const Flex: import("react").MemoExoticComponent<import("react").ForwardR
133
133
  * Forwarded ref element
134
134
  */
135
135
  ref?: any;
136
- } & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "as" | "children" | "wrap" | keyof BasePrimitiveProps> & import("react").RefAttributes<any>>>;
136
+ } & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "wrap" | "as" | "children" | keyof BasePrimitiveProps> & import("react").RefAttributes<any>>>;
137
137
  export default Flex;
@@ -113,5 +113,5 @@ declare const Inline: import("react").MemoExoticComponent<import("react").Forwar
113
113
  * Forwarded ref element
114
114
  */
115
115
  ref?: any;
116
- } & BasePrimitiveProps, "as" | "children" | "space" | "separator" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "rowSpace"> & import("react").RefAttributes<any>>>;
116
+ } & BasePrimitiveProps, "space" | "separator" | "as" | "children" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "rowSpace"> & import("react").RefAttributes<any>>>;
117
117
  export default Inline;
@@ -87,5 +87,5 @@ declare const Stack: import("react").MemoExoticComponent<import("react").Forward
87
87
  * Forwarded ref element
88
88
  */
89
89
  ref?: any;
90
- } & BasePrimitiveProps, "as" | "children" | "space" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
90
+ } & BasePrimitiveProps, "space" | "as" | "children" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
91
91
  export default Stack;