@atlaskit/primitives 0.9.0 → 0.9.1

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 (49) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/constellation/inline/code.mdx +1 -1
  3. package/constellation/stack/code.mdx +1 -1
  4. package/constellation/xcss/examples.mdx +21 -0
  5. package/constellation/xcss/logo.png +0 -0
  6. package/constellation/xcss/migration.mdx +142 -0
  7. package/constellation/xcss/usage.mdx +115 -0
  8. package/dist/cjs/components/box.js +1 -1
  9. package/dist/cjs/components/inline.js +1 -1
  10. package/dist/cjs/components/internal/base-box.js +1 -1
  11. package/dist/cjs/components/stack.js +1 -1
  12. package/dist/cjs/index.js +1 -1
  13. package/dist/cjs/version.json +1 -1
  14. package/dist/cjs/{internal → xcss}/xcss.js +20 -8
  15. package/dist/es2019/components/box.js +1 -1
  16. package/dist/es2019/components/inline.js +1 -1
  17. package/dist/es2019/components/internal/base-box.js +1 -1
  18. package/dist/es2019/components/stack.js +1 -1
  19. package/dist/es2019/index.js +1 -1
  20. package/dist/es2019/version.json +1 -1
  21. package/dist/es2019/{internal → xcss}/xcss.js +19 -6
  22. package/dist/esm/components/box.js +1 -1
  23. package/dist/esm/components/inline.js +1 -1
  24. package/dist/esm/components/internal/base-box.js +1 -1
  25. package/dist/esm/components/stack.js +1 -1
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/version.json +1 -1
  28. package/dist/esm/{internal → xcss}/xcss.js +20 -8
  29. package/dist/types/components/inline.d.ts +1 -1
  30. package/dist/types/components/internal/base-box.d.ts +1 -1
  31. package/dist/types/components/stack.d.ts +1 -1
  32. package/dist/types/components/types.d.ts +1 -1
  33. package/dist/types/index.d.ts +1 -1
  34. package/dist/types/{internal → xcss}/style-maps.partial.d.ts +3 -0
  35. package/dist/types/{internal → xcss}/xcss.d.ts +17 -10
  36. package/package.json +11 -2
  37. package/report.api.md +8 -5
  38. package/tmp/api-report-tmp.d.ts +674 -0
  39. package/dist/cjs/components/internal/extract-react-types/inline-props.js +0 -7
  40. package/dist/cjs/components/internal/extract-react-types/stack-props.js +0 -7
  41. package/dist/es2019/components/internal/extract-react-types/inline-props.js +0 -1
  42. package/dist/es2019/components/internal/extract-react-types/stack-props.js +0 -1
  43. package/dist/esm/components/internal/extract-react-types/inline-props.js +0 -1
  44. package/dist/esm/components/internal/extract-react-types/stack-props.js +0 -1
  45. package/dist/types/components/internal/extract-react-types/inline-props.d.ts +0 -2
  46. package/dist/types/components/internal/extract-react-types/stack-props.d.ts +0 -2
  47. /package/dist/cjs/{internal → xcss}/style-maps.partial.js +0 -0
  48. /package/dist/es2019/{internal → xcss}/style-maps.partial.js +0 -0
  49. /package/dist/esm/{internal → xcss}/style-maps.partial.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5a9e73494eb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5a9e73494eb) - Updates to internal documentation.
8
+
3
9
  ## 0.9.0
4
10
 
5
11
  ### Minor Changes
@@ -4,7 +4,7 @@ description: Inline is a primitive component based on flexbox that manages the h
4
4
  order: 1
5
5
  ---
6
6
 
7
- import InlineProps from '!!extract-react-types-loader!../../src/components/internal/extract-react-types/inline-props'
7
+ import InlineProps from '!!extract-react-types-loader!../../extract-react-types/inline-props'
8
8
 
9
9
  ## Props
10
10
 
@@ -4,7 +4,7 @@ description: Stack is a primitive component based on flexbox that manages the ve
4
4
  order: 1
5
5
  ---
6
6
 
7
- import StackProps from '!!extract-react-types-loader!../../src/components/internal/extract-react-types/stack-props'
7
+ import StackProps from '!!extract-react-types-loader!../../extract-react-types/stack-props'
8
8
 
9
9
  ## Props
10
10
 
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: xCSS
3
+ description: xCSS is a safer, tokens-first approach to CSS-in-JS.
4
+ order: 1
5
+ ---
6
+
7
+ import xcssBasic from '../../examples/constellation/xcss/basic';
8
+ import xcssInteractive from '../../examples/constellation/xcss/interactivity';
9
+
10
+ ## Basic
11
+
12
+ `xcss` can be used to pull together different types of interactions and UI in a safer more composable way.
13
+
14
+ <Example Component={xcssBasic} packageName="@atlaskit/primitives/xcss" />
15
+
16
+ ## Interactivity
17
+
18
+ To enable interactivity you can lean on familiar selectors like `:hover` and `:focus-visible`.
19
+
20
+ <Example Component={xcssInteractive} packageName="@atlaskit/primitives/xcss" />
21
+
Binary file
@@ -0,0 +1,142 @@
1
+ ---
2
+ title: Migrating your app to xCSS
3
+ description: xCSS is a safer, tokens-first approach to CSS-in-JS.
4
+ order: 2
5
+ ---
6
+
7
+ ## Summary of changes
8
+
9
+ ### Changes for developers
10
+
11
+ There are two key changes to be mindful of when migrating to use `xcss`.
12
+ The first is needing to update callsites to remove any nested styles and
13
+ tokenised values.
14
+
15
+ ```diff
16
+ - import { css } from '@emotion/react';
17
+ + import { xcss } from '@atlaskit/primitives';
18
+
19
+ - const someStyles = css({
20
+ + const someStyles = xcss({
21
+ // token based properties will no longer need to be wrapped
22
+ - padding: token('space.100'),
23
+ + padding: 'space.100'
24
+ // no change is required for non-tokenised values
25
+ transform: 'scale(2)'
26
+ });
27
+ ```
28
+
29
+ The second is that for the `xcss` function to be applied correctly it must be applied on a
30
+ component with an `xcss` JSXAttribute. By default this won't work with the `css` or `className`
31
+ JSXAttributes - so be aware if you're not seeing your styles appear.
32
+
33
+ ```diff
34
+ - <div css={someStyles} />
35
+ + <Box xcss={someStyles} />
36
+ ```
37
+
38
+
39
+ #### Changing the way you express styles
40
+
41
+ Why are nested selectors a problem? A key philosophy of `xcss` is encouraging more deterministic style application. This restriction is designed to eliminate side-effects and
42
+ encourage component encapsulation. Consider the below example:
43
+
44
+ ```tsx
45
+ const myComponentStyles = css({
46
+ '> *': {
47
+ color: 'color.text.danger',
48
+ }
49
+ });
50
+
51
+ const MyComponent = () => (
52
+ <div css={myComponentStyles}>
53
+ <p>Text here</p>
54
+ </div>
55
+ );
56
+ ```
57
+
58
+ Here the component is applying styles that are implicity meant for the text wrapped in the `p` below.
59
+ In this simple example, it may seem okay, desirable even, but cases like these often occur across module or component boundaries.
60
+
61
+ This makes the visibility of these dependencies harder to capture or reason about.
62
+ Styles that are inherited or indirectly apply make a UI brittle to change and hard to evolve.
63
+ Instead, if the same styles are applied directly on the affected element we can minimize and in some cases completely eliminate this problem.
64
+
65
+ ```diff
66
+ const myTextStyles = xcss({
67
+ - '> *': {
68
+ color: 'color.text.danger',
69
+ - }
70
+ });
71
+
72
+ const MyComponent = () => (
73
+ - <div xcss={myComponentStyles}>
74
+ + <Box
75
+ + <Text xcss={myTextStyles}>Text here</Text>
76
+ </Box>
77
+ );
78
+ ```
79
+
80
+ There are likely to be cases where nesting is the only option. While not desirable, this is fine as long as it's considered
81
+ a last resort.
82
+
83
+ ### FAQ
84
+
85
+ Overall migration to `xcss` is fairly simple for the majority of cases. Here are some common strategies for migrations.
86
+
87
+ #### Non-tokenised values
88
+
89
+ If you're yet to migrate to tokens, you have two options. You can migrate to tokens first and then on a second pass
90
+ migrate to `xcss` or you can make the jump directly.
91
+
92
+ ```tsx
93
+ const someStyles = css({
94
+ color: 'red',
95
+ });
96
+
97
+ // ->>> Optional middle step
98
+ const someStyles = css({
99
+ color: token('color.text.danger'),
100
+ });
101
+
102
+ // ->>> The final state
103
+ const someStyles = xcss({
104
+ color: 'color.text.danger',
105
+ });
106
+ ```
107
+
108
+ #### Moving from the `styled` API
109
+
110
+ If you're currently using the `styled` API there are a few steps required to migration.
111
+ The safest approach is to a step change to use object styles, migrate to tokens (optionally)
112
+ and then migrate to `xcss`.
113
+
114
+ ```tsx
115
+ const MyComponent = styled.div`
116
+ color: red;
117
+ `;
118
+
119
+ // ->>> move to object styles
120
+ const MyComponent = styled.div({
121
+ color: 'red';
122
+ });
123
+
124
+ // ->>> move to tokens
125
+ const MyComponent = styled.div({
126
+ color: token('color.text.danger'),
127
+ });
128
+
129
+ // ->>> move to Box
130
+ const myComponentStyles = xcss({
131
+ color: 'color.text.danger',
132
+ });
133
+
134
+ const MyComponent = () => <Box xcss={myComponentStyles} />
135
+ ```
136
+
137
+
138
+ ## Get help
139
+
140
+ * Atlassians can reach out in [Slack](slack://channel?team=TFCUTJ0G5&id=CFJ9DU39U) for help with `xcss` migration.
141
+ * Other developers who need help with tokens or the `xcss` utility can post in the [public developer community](https://community.developer.atlassian.com/).
142
+ * For general help with the Atlassian Design System, [contact us](/resources/contact-us).
@@ -0,0 +1,115 @@
1
+ ---
2
+ title: xCSS
3
+ description: xCSS is a safer, tokens-first approach to CSS-in-JS.
4
+ order: 0
5
+ ---
6
+
7
+ ![xcss Logo](logo.png "xcss Logo")
8
+
9
+ `xcss` is an Atlassian Design System styling API designed to natively integrate with
10
+ Atlassian's [design tokens](/tokens) and [primitives](/components/primitives) in a safer, more resilient and evolvable way.
11
+
12
+ The `xcss` utility behaves similarly to the `css` utility in libraries
13
+ like `styled-components`, `@compiled` or `@emotion` - so if you've used those libraries before
14
+ it will feel very familiar, with a few additional features and some constraints.
15
+
16
+ Features that will feel familiar:
17
+
18
+ * `xcss` will generate a `className` to be applied on your components
19
+ * `xcss` will provide key-value pairs of CSS properties in an object format
20
+ * `xcss` supports style precedence and conditional styles
21
+
22
+ But it also has a few key differences.
23
+
24
+ * `xcss` has type-safety that uses token names for all CSS properties that are represented by design tokens.
25
+ * `xcss` restricts nested selectors completely from usage.
26
+
27
+ ## Usage
28
+
29
+ To get started, import the function from `@atlaskit/primitives` and create a style:
30
+
31
+ ```tsx
32
+ import { xcss } from '@atlaskit/primitives';
33
+
34
+ // Creates a basic style
35
+ const someStyles = xcss({
36
+ display: 'block',
37
+ });
38
+ ```
39
+
40
+ Apply this style to a component through the `xcss` prop:
41
+
42
+ ```tsx
43
+ import { Box, xcss } from '@atlaskit/primitives';
44
+
45
+ // Creates a basic style
46
+ const someStyles = xcss({
47
+ display: 'block',
48
+ });
49
+
50
+ const MyBox = () => {
51
+ return <Box xcss={someStyles} />
52
+ }
53
+ ```
54
+
55
+ The prop and the `xcss` function are direct complements and are meant
56
+ to be used together. Note: styles generated from `xcss` cannot be applied directly
57
+ to the `className` property or `css` as they are with other CSS-in-JS libraries.
58
+
59
+ ### Type safety
60
+
61
+ `xcss` uses strongly-typed values generated from design token
62
+ definitions to make it simpler to apply the right token for the right CSS property.
63
+ This is intended to be more ergonomic and intuitive but also prevent the misapplication of tokens
64
+ to the wrong properties.
65
+
66
+ Any [valid token name](/components/tokens/all-tokens) is available to be applied against its
67
+ matching CSS property. For example, the token name `space.200`
68
+ is a valid value below for `padding` but will not appear
69
+ as a color, or a font.
70
+
71
+ ```tsx
72
+ import { xcss } from '@atlaskit/primitives';
73
+
74
+ const someStyles = xcss({
75
+ padding: 'space.200', // <--- works
76
+ color: 'space.200', // <--- invalid and will error
77
+ borderRadius: 'radius.100' // <--- also valid
78
+ });
79
+ ```
80
+
81
+ ### Restricted nesting
82
+
83
+ `xcss` is meant to be flexible enough for you to implement any design but it does
84
+ restrict the application of styles in one key way. Selectors cannot be
85
+ nested or target elements beyond the element on which styles are applied.
86
+ This restriction is intended to encourage better component encapsulation, reduce side-effects and make
87
+ your codebase more resilient to change.
88
+
89
+ ```tsx
90
+ import { xcss } from '@atlaskit/primitives';
91
+
92
+ const someStyles = xcss({
93
+ ':hover': {
94
+ transform: 'scale(1)' // this is okay
95
+ },
96
+ // This is not okay as this selector affects any nested div in
97
+ // the component tree.
98
+ 'div:hover': {
99
+ transform: 'scale(1)'
100
+ },
101
+ // Neither is this
102
+ '> * > div:hover': {
103
+ transform: 'scale(1)'
104
+ },
105
+ });
106
+ ```
107
+
108
+ These unsafe selectors will throw a type error if applied.
109
+ For richer examples of how to use `xcss` please see our [documentation here](/components/primitives/xcss/examples).
110
+
111
+ ## Get help
112
+
113
+ * Atlassians can reach out in [Slack](slack://channel?team=TFCUTJ0G5&id=CFJ9DU39U) for help with `xcss` migration.
114
+ * Other developers who need help with tokens or the `xcss` utility can post in the [public developer community](https://community.developer.atlassian.com/).
115
+ * For general help with the Atlassian Design System, [contact us](/resources/contact-us).
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
10
  var _react = require("react");
11
11
  var _react2 = require("@emotion/react");
12
- var _xcss = require("../internal/xcss");
12
+ var _xcss = require("../xcss/xcss");
13
13
  var _baseBox = require("./internal/base-box");
14
14
  var _excluded = ["as", "children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "style", "testId", "xcss"],
15
15
  _excluded2 = ["className"];
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _react2 = require("@emotion/react");
9
- var _styleMaps = require("../internal/style-maps.partial");
9
+ var _styleMaps = require("../xcss/style-maps.partial");
10
10
  /* eslint-disable @repo/internal/styles/no-exported-styles */
11
11
  /** @jsx jsx */
12
12
 
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
10
  var _react = require("react");
11
11
  var _react2 = require("@emotion/react");
12
- var _styleMaps = require("../../internal/style-maps.partial");
12
+ var _styleMaps = require("../../xcss/style-maps.partial");
13
13
  var _excluded = ["as", "className", "children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "style", "testId"];
14
14
  /* eslint-disable @repo/internal/styles/no-exported-styles */
15
15
  /** @jsx jsx */
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _react2 = require("@emotion/react");
9
- var _styleMaps = require("../internal/style-maps.partial");
9
+ var _styleMaps = require("../xcss/style-maps.partial");
10
10
  /* eslint-disable @repo/internal/styles/no-exported-styles */
11
11
  /** @jsx jsx */
12
12
 
package/dist/cjs/index.js CHANGED
@@ -30,5 +30,5 @@ Object.defineProperty(exports, "xcss", {
30
30
  });
31
31
  var _box = _interopRequireDefault(require("./components/box"));
32
32
  var _inline = _interopRequireDefault(require("./components/inline"));
33
- var _xcss = require("./internal/xcss");
33
+ var _xcss = require("./xcss/xcss");
34
34
  var _stack = _interopRequireDefault(require("./components/stack"));
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "sideEffects": false
5
5
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.parseXcss = void 0;
8
8
  exports.xcss = xcss;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
11
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
12
  var _react = require("@emotion/react");
@@ -49,6 +50,9 @@ var tokensMap = {
49
50
  minHeight: _styleMaps.dimensionMap,
50
51
  minInlineSize: _styleMaps.dimensionMap,
51
52
  minWidth: _styleMaps.dimensionMap,
53
+ outlineOffset: _styleMaps.paddingMap,
54
+ outlineWidth: _styleMaps.borderWidthMap,
55
+ outlineColor: _styleMaps.borderColorMap,
52
56
  overflow: _styleMaps.overflowMap,
53
57
  overflowBlock: _styleMaps.overflowBlockMap,
54
58
  overflowInline: _styleMaps.overflowInlineMap,
@@ -70,7 +74,7 @@ var tokensMap = {
70
74
  width: _styleMaps.dimensionMap,
71
75
  zIndex: _styleMaps.layerMap
72
76
  };
73
- var uniqueSymbol = Symbol('Internal symbol to verify xcss function is called safely');
77
+ var uniqueSymbol = Symbol('UNSAFE_INTERNAL_styles');
74
78
  var isSafeEnvToThrow = function isSafeEnvToThrow() {
75
79
  return (typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) === 'object' && (0, _typeof2.default)(process.env) === 'object' && process.env.NODE_ENV !== 'production';
76
80
  };
@@ -124,10 +128,7 @@ var transformStyles = function transformStyles(styleObj) {
124
128
  };
125
129
  var baseXcss = function baseXcss(style) {
126
130
  var transformedStyles = transformStyles(style);
127
- return {
128
- symbol: uniqueSymbol,
129
- styles: (0, _react.css)(transformedStyles)
130
- };
131
+ return (0, _defineProperty2.default)({}, uniqueSymbol, (0, _react.css)(transformedStyles));
131
132
  };
132
133
 
133
134
  /**
@@ -141,9 +142,8 @@ var parseXcss = function parseXcss(args) {
141
142
  return x && parseXcss(x);
142
143
  }).filter(Boolean);
143
144
  }
144
- var symbol = args.symbol,
145
- styles = args.styles;
146
- if ((typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) && process.env.NODE_ENV === 'development' && symbol !== uniqueSymbol) {
145
+ var styles = args[uniqueSymbol];
146
+ if ((typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) && process.env.NODE_ENV === 'development' && typeof styles === 'undefined') {
147
147
  throw new Error('Styles generated from unsafe source, use the `xcss` export from `@atlaskit/primitives`.');
148
148
  }
149
149
  return styles;
@@ -156,6 +156,18 @@ var boxWrapper = function boxWrapper(style) {
156
156
  var inlineWrapper = function inlineWrapper(style) {
157
157
  return xcss(style);
158
158
  };
159
+ /**
160
+ * ### xcss
161
+ *
162
+ * `xcss` is a safer, tokens-first approach to CSS-in-JS. It allows token-backed values for
163
+ * CSS application.
164
+ *
165
+ * ```tsx
166
+ * const styles = xcss({
167
+ * padding: 'space.100'
168
+ * })
169
+ * ```
170
+ */
159
171
  function xcss(style) {
160
172
  return baseXcss(style);
161
173
  }
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
  import { forwardRef } from 'react';
4
4
  import { jsx } from '@emotion/react';
5
- import { parseXcss } from '../internal/xcss';
5
+ import { parseXcss } from '../xcss/xcss';
6
6
  import { BaseBox } from './internal/base-box';
7
7
  /**
8
8
  * __Box__
@@ -2,7 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { Children, forwardRef, Fragment, memo } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
- import { spaceStylesMap } from '../internal/style-maps.partial';
5
+ import { spaceStylesMap } from '../xcss/style-maps.partial';
6
6
  const alignItemsMap = {
7
7
  center: css({
8
8
  alignItems: 'center'
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  /** @jsx jsx */
4
4
  import { forwardRef } from 'react';
5
5
  import { css, jsx } from '@emotion/react';
6
- import { backgroundColorStylesMap, paddingStylesMap } from '../../internal/style-maps.partial';
6
+ import { backgroundColorStylesMap, paddingStylesMap } from '../../xcss/style-maps.partial';
7
7
 
8
8
  // Without this type annotation on Box we don't get autocomplete for props due to forwardRef types
9
9
 
@@ -2,7 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { forwardRef, memo } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
- import { spaceStylesMap } from '../internal/style-maps.partial';
5
+ import { spaceStylesMap } from '../xcss/style-maps.partial';
6
6
  const justifyContentMap = {
7
7
  start: css({
8
8
  justifyContent: 'start'
@@ -1,4 +1,4 @@
1
1
  export { default as Box } from './components/box';
2
2
  export { default as Inline } from './components/inline';
3
- export { xcss } from './internal/xcss';
3
+ export { xcss } from './xcss/xcss';
4
4
  export { default as Stack } from './components/stack';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "sideEffects": false
5
5
  }
@@ -38,6 +38,9 @@ const tokensMap = {
38
38
  minHeight: dimensionMap,
39
39
  minInlineSize: dimensionMap,
40
40
  minWidth: dimensionMap,
41
+ outlineOffset: paddingMap,
42
+ outlineWidth: borderWidthMap,
43
+ outlineColor: borderColorMap,
41
44
  overflow: overflowMap,
42
45
  overflowBlock: overflowBlockMap,
43
46
  overflowInline: overflowInlineMap,
@@ -59,7 +62,7 @@ const tokensMap = {
59
62
  width: dimensionMap,
60
63
  zIndex: layerMap
61
64
  };
62
- const uniqueSymbol = Symbol('Internal symbol to verify xcss function is called safely');
65
+ const uniqueSymbol = Symbol('UNSAFE_INTERNAL_styles');
63
66
  const isSafeEnvToThrow = () => typeof process === 'object' && typeof process.env === 'object' && process.env.NODE_ENV !== 'production';
64
67
  const reNestedSelectors = /(\.|\s|&+|\*\>|#|\[.*\])/;
65
68
  const rePseudos = /^::?.*$/;
@@ -109,8 +112,7 @@ const transformStyles = styleObj => {
109
112
  const baseXcss = style => {
110
113
  const transformedStyles = transformStyles(style);
111
114
  return {
112
- symbol: uniqueSymbol,
113
- styles: cssEmotion(transformedStyles)
115
+ [uniqueSymbol]: cssEmotion(transformedStyles)
114
116
  };
115
117
  };
116
118
 
@@ -124,10 +126,9 @@ export const parseXcss = args => {
124
126
  return args.map(x => x && parseXcss(x)).filter(Boolean);
125
127
  }
126
128
  const {
127
- symbol,
128
- styles
129
+ [uniqueSymbol]: styles
129
130
  } = args;
130
- if (typeof process && process.env.NODE_ENV === 'development' && symbol !== uniqueSymbol) {
131
+ if (typeof process && process.env.NODE_ENV === 'development' && typeof styles === 'undefined') {
131
132
  throw new Error('Styles generated from unsafe source, use the `xcss` export from `@atlaskit/primitives`.');
132
133
  }
133
134
  return styles;
@@ -135,6 +136,18 @@ export const parseXcss = args => {
135
136
  // unused private functions only so we can extract the return type from a generic function
136
137
  const boxWrapper = style => xcss(style);
137
138
  const inlineWrapper = style => xcss(style);
139
+ /**
140
+ * ### xcss
141
+ *
142
+ * `xcss` is a safer, tokens-first approach to CSS-in-JS. It allows token-backed values for
143
+ * CSS application.
144
+ *
145
+ * ```tsx
146
+ * const styles = xcss({
147
+ * padding: 'space.100'
148
+ * })
149
+ * ```
150
+ */
138
151
  export function xcss(style) {
139
152
  return baseXcss(style);
140
153
  }
@@ -5,7 +5,7 @@ var _excluded = ["as", "children", "backgroundColor", "padding", "paddingBlock",
5
5
  /** @jsx jsx */
6
6
  import { forwardRef } from 'react';
7
7
  import { jsx } from '@emotion/react';
8
- import { parseXcss } from '../internal/xcss';
8
+ import { parseXcss } from '../xcss/xcss';
9
9
  import { BaseBox } from './internal/base-box';
10
10
  /**
11
11
  * __Box__
@@ -2,7 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { Children, forwardRef, Fragment, memo } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
- import { spaceStylesMap } from '../internal/style-maps.partial';
5
+ import { spaceStylesMap } from '../xcss/style-maps.partial';
6
6
  var alignItemsMap = {
7
7
  center: css({
8
8
  alignItems: 'center'
@@ -5,7 +5,7 @@ var _excluded = ["as", "className", "children", "backgroundColor", "padding", "p
5
5
  /** @jsx jsx */
6
6
  import { forwardRef } from 'react';
7
7
  import { css, jsx } from '@emotion/react';
8
- import { backgroundColorStylesMap, paddingStylesMap } from '../../internal/style-maps.partial';
8
+ import { backgroundColorStylesMap, paddingStylesMap } from '../../xcss/style-maps.partial';
9
9
 
10
10
  // Without this type annotation on Box we don't get autocomplete for props due to forwardRef types
11
11
 
@@ -2,7 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { forwardRef, memo } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
- import { spaceStylesMap } from '../internal/style-maps.partial';
5
+ import { spaceStylesMap } from '../xcss/style-maps.partial';
6
6
  var justifyContentMap = {
7
7
  start: css({
8
8
  justifyContent: 'start'
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as Box } from './components/box';
2
2
  export { default as Inline } from './components/inline';
3
- export { xcss } from './internal/xcss';
3
+ export { xcss } from './xcss/xcss';
4
4
  export { default as Stack } from './components/stack';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "sideEffects": false
5
5
  }