@atlaskit/primitives 0.9.0 → 0.9.2

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 (73) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +6 -2
  3. package/box/package.json +2 -2
  4. package/constellation/box/code.mdx +6 -2
  5. package/constellation/box/usage.mdx +30 -0
  6. package/constellation/inline/code.mdx +1 -1
  7. package/constellation/inline/usage.mdx +36 -0
  8. package/constellation/overview/images/box-usage-example.png +0 -0
  9. package/constellation/overview/images/inline-usage-example.png +0 -0
  10. package/constellation/overview/images/stack-usage-example.png +0 -0
  11. package/constellation/overview/index.mdx +66 -0
  12. package/constellation/stack/code.mdx +1 -1
  13. package/constellation/stack/usage.mdx +31 -0
  14. package/constellation/xcss/examples.mdx +21 -0
  15. package/constellation/xcss/logo.png +0 -0
  16. package/constellation/xcss/migration.mdx +142 -0
  17. package/constellation/xcss/usage.mdx +115 -0
  18. package/dist/cjs/components/box.js +1 -1
  19. package/dist/cjs/components/inline.js +1 -1
  20. package/dist/cjs/components/internal/base-box.js +1 -1
  21. package/dist/cjs/components/stack.js +1 -1
  22. package/dist/cjs/index.js +1 -1
  23. package/dist/cjs/version.json +1 -1
  24. package/dist/cjs/{internal → xcss}/style-maps.partial.js +13 -43
  25. package/dist/cjs/{internal → xcss}/xcss.js +38 -26
  26. package/dist/es2019/components/box.js +1 -1
  27. package/dist/es2019/components/inline.js +1 -1
  28. package/dist/es2019/components/internal/base-box.js +1 -1
  29. package/dist/es2019/components/stack.js +1 -1
  30. package/dist/es2019/index.js +1 -1
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/es2019/{internal → xcss}/style-maps.partial.js +12 -40
  33. package/dist/es2019/{internal → xcss}/xcss.js +38 -25
  34. package/dist/esm/components/box.js +1 -1
  35. package/dist/esm/components/inline.js +1 -1
  36. package/dist/esm/components/internal/base-box.js +1 -1
  37. package/dist/esm/components/stack.js +1 -1
  38. package/dist/esm/index.js +1 -1
  39. package/dist/esm/version.json +1 -1
  40. package/dist/esm/{internal → xcss}/style-maps.partial.js +12 -40
  41. package/dist/esm/{internal → xcss}/xcss.js +39 -27
  42. package/dist/types/components/box.d.ts +2 -2
  43. package/dist/types/components/inline.d.ts +7 -7
  44. package/dist/types/components/internal/base-box.d.ts +15 -14
  45. package/dist/types/components/stack.d.ts +6 -6
  46. package/dist/types/components/types.d.ts +3 -3
  47. package/dist/types/constants.d.ts +1 -1
  48. package/dist/types/helpers/responsive/types.d.ts +4 -4
  49. package/dist/types/index.d.ts +1 -1
  50. package/dist/types/{internal → xcss}/style-maps.partial.d.ts +81 -130
  51. package/dist/types/xcss/xcss.d.ts +57 -0
  52. package/extract-react-types/box-props.tsx +95 -0
  53. package/extract-react-types/inline-props.tsx +86 -1
  54. package/extract-react-types/stack-props.tsx +70 -1
  55. package/inline/package.json +2 -2
  56. package/package.json +25 -8
  57. package/report.api.md +94 -354
  58. package/responsive/package.json +2 -2
  59. package/scripts/codegen-file-templates/dimensions.tsx +17 -16
  60. package/scripts/codegen-styles.tsx +2 -2
  61. package/scripts/spacing-codegen-template.tsx +24 -91
  62. package/stack/package.json +2 -2
  63. package/tmp/api-report-tmp.d.ts +649 -0
  64. package/constellation/overview/examples.mdx +0 -7
  65. package/dist/cjs/components/internal/extract-react-types/inline-props.js +0 -7
  66. package/dist/cjs/components/internal/extract-react-types/stack-props.js +0 -7
  67. package/dist/es2019/components/internal/extract-react-types/inline-props.js +0 -1
  68. package/dist/es2019/components/internal/extract-react-types/stack-props.js +0 -1
  69. package/dist/esm/components/internal/extract-react-types/inline-props.js +0 -1
  70. package/dist/esm/components/internal/extract-react-types/stack-props.js +0 -1
  71. package/dist/types/components/internal/extract-react-types/inline-props.d.ts +0 -2
  72. package/dist/types/components/internal/extract-react-types/stack-props.d.ts +0 -2
  73. package/dist/types/internal/xcss.d.ts +0 -50
@@ -4,16 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.textColorMap = exports.spaceStylesMap = exports.spaceMap = exports.shadowMap = exports.positionMap = exports.paddingStylesMap = exports.paddingMap = exports.overflowMap = exports.overflowInlineMap = exports.overflowBlockMap = exports.layerMap = exports.insetMap = exports.flexShrinkMap = exports.flexMap = exports.flexGrowMap = exports.flexDirectionMap = exports.displayMap = exports.dimensionMap = exports.borderWidthMap = exports.borderStyleMap = exports.borderRadiusMap = exports.borderColorMap = exports.backgroundColorStylesMap = exports.backgroundColorMap = exports.alignSelfMap = void 0;
7
+ exports.textColorMap = exports.spaceStylesMap = exports.spaceMap = exports.shadowMap = exports.positionMap = exports.paddingStylesMap = exports.overflowMap = exports.overflowInlineMap = exports.overflowBlockMap = exports.layerMap = exports.flexShrinkMap = exports.flexMap = exports.flexGrowMap = exports.flexDirectionMap = exports.displayMap = exports.dimensionMap = exports.borderWidthMap = exports.borderStyleMap = exports.borderRadiusMap = exports.borderColorMap = exports.backgroundColorStylesMap = exports.backgroundColorMap = exports.alignSelfMap = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("@emotion/react");
10
10
  /**
11
11
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
12
- * @codegen <<SignedSource::fc517b480964965a9d7e6e5c8d921c19>>
12
+ * @codegen <<SignedSource::7d4a8604dc454e30c0fec5c1330ea7c5>>
13
13
  * @codegenId dimensions
14
14
  * @codegenCommand yarn codegen-styles
15
15
  * @codegenParams ["dimensions"]
16
- * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::9e8ad113b10e9429c514c69bd362f479>>
16
+ * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::dbad5eb9ef292d4ec59f90459a81e1d6>>
17
17
  */
18
18
  var dimensionMap = {
19
19
  '100%': '100%',
@@ -32,29 +32,11 @@ exports.dimensionMap = dimensionMap;
32
32
 
33
33
  /**
34
34
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
35
- * @codegen <<SignedSource::8ce817b8abf862e7945a9c9792a1255e>>
35
+ * @codegen <<SignedSource::9fbc4dfcd8f43f52bff6b3bb666397fe>>
36
36
  * @codegenId spacing
37
37
  * @codegenCommand yarn codegen-styles
38
- * @codegenParams ["padding", "space", "inset"]
39
38
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
40
39
  */
41
- var paddingMap = {
42
- 'space.0': "var(--ds-space-0, 0px)",
43
- 'space.025': "var(--ds-space-025, 2px)",
44
- 'space.050': "var(--ds-space-050, 4px)",
45
- 'space.075': "var(--ds-space-075, 6px)",
46
- 'space.100': "var(--ds-space-100, 8px)",
47
- 'space.150': "var(--ds-space-150, 12px)",
48
- 'space.200': "var(--ds-space-200, 16px)",
49
- 'space.250': "var(--ds-space-250, 20px)",
50
- 'space.300': "var(--ds-space-300, 24px)",
51
- 'space.400': "var(--ds-space-400, 32px)",
52
- 'space.500': "var(--ds-space-500, 40px)",
53
- 'space.600': "var(--ds-space-600, 48px)",
54
- 'space.800': "var(--ds-space-800, 64px)",
55
- 'space.1000': "var(--ds-space-1000, 80px)"
56
- };
57
- exports.paddingMap = paddingMap;
58
40
  var spaceMap = {
59
41
  'space.0': "var(--ds-space-0, 0px)",
60
42
  'space.025': "var(--ds-space-025, 2px)",
@@ -72,23 +54,6 @@ var spaceMap = {
72
54
  'space.1000': "var(--ds-space-1000, 80px)"
73
55
  };
74
56
  exports.spaceMap = spaceMap;
75
- var insetMap = {
76
- 'space.0': "var(--ds-space-0, 0px)",
77
- 'space.025': "var(--ds-space-025, 2px)",
78
- 'space.050': "var(--ds-space-050, 4px)",
79
- 'space.075': "var(--ds-space-075, 6px)",
80
- 'space.100': "var(--ds-space-100, 8px)",
81
- 'space.150': "var(--ds-space-150, 12px)",
82
- 'space.200': "var(--ds-space-200, 16px)",
83
- 'space.250': "var(--ds-space-250, 20px)",
84
- 'space.300': "var(--ds-space-300, 24px)",
85
- 'space.400': "var(--ds-space-400, 32px)",
86
- 'space.500': "var(--ds-space-500, 40px)",
87
- 'space.600': "var(--ds-space-600, 48px)",
88
- 'space.800': "var(--ds-space-800, 64px)",
89
- 'space.1000': "var(--ds-space-1000, 80px)"
90
- };
91
- exports.insetMap = insetMap;
92
57
  /**
93
58
  * @codegenEnd
94
59
  */
@@ -281,13 +246,13 @@ exports.textColorMap = textColorMap;
281
246
 
282
247
  /**
283
248
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
284
- * @codegen <<SignedSource::8838ca696c1fa533db0eb127be15d81e>>
249
+ * @codegen <<SignedSource::64f7b08cdbce710fba3157594ea695a8>>
285
250
  * @codegenId misc
286
251
  * @codegenCommand yarn codegen-styles
287
252
  * @codegenParams ["align-self", "border-style", "display", "flex-direction", "flex-grow", "flex-shrink", "flex", "layer", "overflow", "position"]
288
253
  * @codegenDependency ../../scripts/codegen-file-templates/align-self.tsx <<SignedSource::074079802534462de54bf882bb2073e5>>
289
254
  * @codegenDependency ../../scripts/codegen-file-templates/border-style.tsx <<SignedSource::87e7e289ffeaac901997c4af98084a5f>>
290
- * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::9e8ad113b10e9429c514c69bd362f479>>
255
+ * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::dbad5eb9ef292d4ec59f90459a81e1d6>>
291
256
  * @codegenDependency ../../scripts/codegen-file-templates/display.tsx <<SignedSource::04ea30fcb3c02f2545af7fdc0206e645>>
292
257
  * @codegenDependency ../../scripts/codegen-file-templates/flex-direction.tsx <<SignedSource::19809ba11675679c188b0d98fb651dc1>>
293
258
  * @codegenDependency ../../scripts/codegen-file-templates/flex-grow.tsx <<SignedSource::b8a06b122cb609170f1f42778a6c270e>>
@@ -402,7 +367,12 @@ var borderRadiusMap = {
402
367
  * @codegenEnd
403
368
  */
404
369
  exports.borderRadiusMap = borderRadiusMap;
405
- var spacingProperties = ['padding', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'gap', 'rowGap', 'columnGap'];
370
+ // Generate maps for Box props. backgroundColor, padding, etc
371
+ var spacingProperties = [
372
+ // Used by Box
373
+ 'padding', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd',
374
+ // Used by Inline and Stack
375
+ 'gap', 'rowGap', 'columnGap'];
406
376
  var getSerializedStylesMap = function getSerializedStylesMap(cssProperty, tokenMap) {
407
377
  return Object.keys(tokenMap).reduce(function (emotionSpacingMap, token) {
408
378
  emotionSpacingMap[token] = (0, _react.css)((0, _defineProperty2.default)({}, cssProperty, tokenMap[token]));
@@ -410,7 +380,7 @@ var getSerializedStylesMap = function getSerializedStylesMap(cssProperty, tokenM
410
380
  }, {});
411
381
  };
412
382
  var paddingStylesMap = spacingProperties.reduce(function (styleMap, spacingProperty) {
413
- styleMap[spacingProperty] = getSerializedStylesMap(spacingProperty, paddingMap);
383
+ styleMap[spacingProperty] = getSerializedStylesMap(spacingProperty, spaceMap);
414
384
  return styleMap;
415
385
  }, {});
416
386
  exports.paddingStylesMap = paddingStylesMap;
@@ -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");
@@ -33,13 +34,13 @@ var tokensMap = {
33
34
  gap: _styleMaps.spaceMap,
34
35
  height: _styleMaps.dimensionMap,
35
36
  inlineSize: _styleMaps.dimensionMap,
36
- inset: _styleMaps.insetMap,
37
- insetBlock: _styleMaps.insetMap,
38
- insetBlockEnd: _styleMaps.insetMap,
39
- insetBlockStart: _styleMaps.insetMap,
40
- insetInline: _styleMaps.insetMap,
41
- insetInlineEnd: _styleMaps.insetMap,
42
- insetInlineStart: _styleMaps.insetMap,
37
+ inset: _styleMaps.spaceMap,
38
+ insetBlock: _styleMaps.spaceMap,
39
+ insetBlockEnd: _styleMaps.spaceMap,
40
+ insetBlockStart: _styleMaps.spaceMap,
41
+ insetInline: _styleMaps.spaceMap,
42
+ insetInlineEnd: _styleMaps.spaceMap,
43
+ insetInlineStart: _styleMaps.spaceMap,
43
44
  left: _styleMaps.dimensionMap,
44
45
  maxBlockSize: _styleMaps.dimensionMap,
45
46
  maxHeight: _styleMaps.dimensionMap,
@@ -49,20 +50,23 @@ var tokensMap = {
49
50
  minHeight: _styleMaps.dimensionMap,
50
51
  minInlineSize: _styleMaps.dimensionMap,
51
52
  minWidth: _styleMaps.dimensionMap,
53
+ outlineOffset: _styleMaps.spaceMap,
54
+ outlineWidth: _styleMaps.borderWidthMap,
55
+ outlineColor: _styleMaps.borderColorMap,
52
56
  overflow: _styleMaps.overflowMap,
53
57
  overflowBlock: _styleMaps.overflowBlockMap,
54
58
  overflowInline: _styleMaps.overflowInlineMap,
55
- padding: _styleMaps.paddingMap,
56
- paddingBlock: _styleMaps.paddingMap,
57
- paddingBlockEnd: _styleMaps.paddingMap,
58
- paddingBlockStart: _styleMaps.paddingMap,
59
- paddingBottom: _styleMaps.paddingMap,
60
- paddingInline: _styleMaps.paddingMap,
61
- paddingInlineEnd: _styleMaps.paddingMap,
62
- paddingInlineStart: _styleMaps.paddingMap,
63
- paddingLeft: _styleMaps.paddingMap,
64
- paddingRight: _styleMaps.paddingMap,
65
- paddingTop: _styleMaps.paddingMap,
59
+ padding: _styleMaps.spaceMap,
60
+ paddingBlock: _styleMaps.spaceMap,
61
+ paddingBlockEnd: _styleMaps.spaceMap,
62
+ paddingBlockStart: _styleMaps.spaceMap,
63
+ paddingBottom: _styleMaps.spaceMap,
64
+ paddingInline: _styleMaps.spaceMap,
65
+ paddingInlineEnd: _styleMaps.spaceMap,
66
+ paddingInlineStart: _styleMaps.spaceMap,
67
+ paddingLeft: _styleMaps.spaceMap,
68
+ paddingRight: _styleMaps.spaceMap,
69
+ paddingTop: _styleMaps.spaceMap,
66
70
  position: _styleMaps.positionMap,
67
71
  right: _styleMaps.dimensionMap,
68
72
  rowGap: _styleMaps.spaceMap,
@@ -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.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,11 +1,11 @@
1
1
  import { css } from '@emotion/react';
2
2
  /**
3
3
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
4
- * @codegen <<SignedSource::fc517b480964965a9d7e6e5c8d921c19>>
4
+ * @codegen <<SignedSource::7d4a8604dc454e30c0fec5c1330ea7c5>>
5
5
  * @codegenId dimensions
6
6
  * @codegenCommand yarn codegen-styles
7
7
  * @codegenParams ["dimensions"]
8
- * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::9e8ad113b10e9429c514c69bd362f479>>
8
+ * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::dbad5eb9ef292d4ec59f90459a81e1d6>>
9
9
  */
10
10
  export const dimensionMap = {
11
11
  '100%': '100%',
@@ -22,28 +22,11 @@ export const dimensionMap = {
22
22
  */
23
23
  /**
24
24
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
25
- * @codegen <<SignedSource::8ce817b8abf862e7945a9c9792a1255e>>
25
+ * @codegen <<SignedSource::9fbc4dfcd8f43f52bff6b3bb666397fe>>
26
26
  * @codegenId spacing
27
27
  * @codegenCommand yarn codegen-styles
28
- * @codegenParams ["padding", "space", "inset"]
29
28
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
30
29
  */
31
- export const paddingMap = {
32
- 'space.0': "var(--ds-space-0, 0px)",
33
- 'space.025': "var(--ds-space-025, 2px)",
34
- 'space.050': "var(--ds-space-050, 4px)",
35
- 'space.075': "var(--ds-space-075, 6px)",
36
- 'space.100': "var(--ds-space-100, 8px)",
37
- 'space.150': "var(--ds-space-150, 12px)",
38
- 'space.200': "var(--ds-space-200, 16px)",
39
- 'space.250': "var(--ds-space-250, 20px)",
40
- 'space.300': "var(--ds-space-300, 24px)",
41
- 'space.400': "var(--ds-space-400, 32px)",
42
- 'space.500': "var(--ds-space-500, 40px)",
43
- 'space.600': "var(--ds-space-600, 48px)",
44
- 'space.800': "var(--ds-space-800, 64px)",
45
- 'space.1000': "var(--ds-space-1000, 80px)"
46
- };
47
30
  export const spaceMap = {
48
31
  'space.0': "var(--ds-space-0, 0px)",
49
32
  'space.025': "var(--ds-space-025, 2px)",
@@ -60,22 +43,6 @@ export const spaceMap = {
60
43
  'space.800': "var(--ds-space-800, 64px)",
61
44
  'space.1000': "var(--ds-space-1000, 80px)"
62
45
  };
63
- export const insetMap = {
64
- 'space.0': "var(--ds-space-0, 0px)",
65
- 'space.025': "var(--ds-space-025, 2px)",
66
- 'space.050': "var(--ds-space-050, 4px)",
67
- 'space.075': "var(--ds-space-075, 6px)",
68
- 'space.100': "var(--ds-space-100, 8px)",
69
- 'space.150': "var(--ds-space-150, 12px)",
70
- 'space.200': "var(--ds-space-200, 16px)",
71
- 'space.250': "var(--ds-space-250, 20px)",
72
- 'space.300': "var(--ds-space-300, 24px)",
73
- 'space.400': "var(--ds-space-400, 32px)",
74
- 'space.500': "var(--ds-space-500, 40px)",
75
- 'space.600': "var(--ds-space-600, 48px)",
76
- 'space.800': "var(--ds-space-800, 64px)",
77
- 'space.1000': "var(--ds-space-1000, 80px)"
78
- };
79
46
  /**
80
47
  * @codegenEnd
81
48
  */
@@ -262,13 +229,13 @@ export const textColorMap = {
262
229
  */
263
230
  /**
264
231
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
265
- * @codegen <<SignedSource::8838ca696c1fa533db0eb127be15d81e>>
232
+ * @codegen <<SignedSource::64f7b08cdbce710fba3157594ea695a8>>
266
233
  * @codegenId misc
267
234
  * @codegenCommand yarn codegen-styles
268
235
  * @codegenParams ["align-self", "border-style", "display", "flex-direction", "flex-grow", "flex-shrink", "flex", "layer", "overflow", "position"]
269
236
  * @codegenDependency ../../scripts/codegen-file-templates/align-self.tsx <<SignedSource::074079802534462de54bf882bb2073e5>>
270
237
  * @codegenDependency ../../scripts/codegen-file-templates/border-style.tsx <<SignedSource::87e7e289ffeaac901997c4af98084a5f>>
271
- * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::9e8ad113b10e9429c514c69bd362f479>>
238
+ * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::dbad5eb9ef292d4ec59f90459a81e1d6>>
272
239
  * @codegenDependency ../../scripts/codegen-file-templates/display.tsx <<SignedSource::04ea30fcb3c02f2545af7fdc0206e645>>
273
240
  * @codegenDependency ../../scripts/codegen-file-templates/flex-direction.tsx <<SignedSource::19809ba11675679c188b0d98fb651dc1>>
274
241
  * @codegenDependency ../../scripts/codegen-file-templates/flex-grow.tsx <<SignedSource::b8a06b122cb609170f1f42778a6c270e>>
@@ -369,7 +336,12 @@ export const borderRadiusMap = {
369
336
  * @codegenEnd
370
337
  */
371
338
 
372
- const spacingProperties = ['padding', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'gap', 'rowGap', 'columnGap'];
339
+ // Generate maps for Box props. backgroundColor, padding, etc
340
+ const spacingProperties = [
341
+ // Used by Box
342
+ 'padding', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd',
343
+ // Used by Inline and Stack
344
+ 'gap', 'rowGap', 'columnGap'];
373
345
  const getSerializedStylesMap = (cssProperty, tokenMap) => {
374
346
  return Object.keys(tokenMap).reduce((emotionSpacingMap, token) => {
375
347
  emotionSpacingMap[token] = css({
@@ -379,7 +351,7 @@ const getSerializedStylesMap = (cssProperty, tokenMap) => {
379
351
  }, {});
380
352
  };
381
353
  export const paddingStylesMap = spacingProperties.reduce((styleMap, spacingProperty) => {
382
- styleMap[spacingProperty] = getSerializedStylesMap(spacingProperty, paddingMap);
354
+ styleMap[spacingProperty] = getSerializedStylesMap(spacingProperty, spaceMap);
383
355
  return styleMap;
384
356
  }, {});
385
357
  export const spaceStylesMap = spacingProperties.reduce((styleMap, spacingProperty) => {
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
2
  import { css as cssEmotion } from '@emotion/react';
3
3
  import warnOnce from '@atlaskit/ds-lib/warn-once';
4
- import { alignSelfMap, backgroundColorMap, borderColorMap, borderRadiusMap, borderStyleMap, borderWidthMap, dimensionMap, displayMap, flexDirectionMap, flexGrowMap, flexMap, flexShrinkMap, insetMap, layerMap, overflowBlockMap, overflowInlineMap, overflowMap, paddingMap, positionMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
4
+ import { alignSelfMap, backgroundColorMap, borderColorMap, borderRadiusMap, borderStyleMap, borderWidthMap, dimensionMap, displayMap, flexDirectionMap, flexGrowMap, flexMap, flexShrinkMap, layerMap, overflowBlockMap, overflowInlineMap, overflowMap, positionMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
5
5
  const tokensMap = {
6
6
  alignSelf: alignSelfMap,
7
7
  backgroundColor: backgroundColorMap,
@@ -22,13 +22,13 @@ const tokensMap = {
22
22
  gap: spaceMap,
23
23
  height: dimensionMap,
24
24
  inlineSize: dimensionMap,
25
- inset: insetMap,
26
- insetBlock: insetMap,
27
- insetBlockEnd: insetMap,
28
- insetBlockStart: insetMap,
29
- insetInline: insetMap,
30
- insetInlineEnd: insetMap,
31
- insetInlineStart: insetMap,
25
+ inset: spaceMap,
26
+ insetBlock: spaceMap,
27
+ insetBlockEnd: spaceMap,
28
+ insetBlockStart: spaceMap,
29
+ insetInline: spaceMap,
30
+ insetInlineEnd: spaceMap,
31
+ insetInlineStart: spaceMap,
32
32
  left: dimensionMap,
33
33
  maxBlockSize: dimensionMap,
34
34
  maxHeight: dimensionMap,
@@ -38,20 +38,23 @@ const tokensMap = {
38
38
  minHeight: dimensionMap,
39
39
  minInlineSize: dimensionMap,
40
40
  minWidth: dimensionMap,
41
+ outlineOffset: spaceMap,
42
+ outlineWidth: borderWidthMap,
43
+ outlineColor: borderColorMap,
41
44
  overflow: overflowMap,
42
45
  overflowBlock: overflowBlockMap,
43
46
  overflowInline: overflowInlineMap,
44
- padding: paddingMap,
45
- paddingBlock: paddingMap,
46
- paddingBlockEnd: paddingMap,
47
- paddingBlockStart: paddingMap,
48
- paddingBottom: paddingMap,
49
- paddingInline: paddingMap,
50
- paddingInlineEnd: paddingMap,
51
- paddingInlineStart: paddingMap,
52
- paddingLeft: paddingMap,
53
- paddingRight: paddingMap,
54
- paddingTop: paddingMap,
47
+ padding: spaceMap,
48
+ paddingBlock: spaceMap,
49
+ paddingBlockEnd: spaceMap,
50
+ paddingBlockStart: spaceMap,
51
+ paddingBottom: spaceMap,
52
+ paddingInline: spaceMap,
53
+ paddingInlineEnd: spaceMap,
54
+ paddingInlineStart: spaceMap,
55
+ paddingLeft: spaceMap,
56
+ paddingRight: spaceMap,
57
+ paddingTop: spaceMap,
55
58
  position: positionMap,
56
59
  right: dimensionMap,
57
60
  rowGap: spaceMap,
@@ -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.2",
4
4
  "sideEffects": false
5
5
  }