@atlaskit/primitives 0.2.0 → 0.2.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 (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/components/box.js +14 -2
  3. package/dist/cjs/components/inline.partial.js +47 -23
  4. package/dist/cjs/components/internal/base-box.partial.js +99 -78
  5. package/dist/cjs/components/internal/types.js +8 -0
  6. package/dist/cjs/components/internal/utils.js +16 -0
  7. package/dist/cjs/components/stack.partial.js +46 -22
  8. package/dist/cjs/constants.js +13 -0
  9. package/dist/cjs/index.js +2 -2
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/components/box.js +12 -1
  12. package/dist/es2019/components/inline.partial.js +19 -19
  13. package/dist/es2019/components/internal/base-box.partial.js +75 -70
  14. package/dist/es2019/components/internal/types.js +1 -0
  15. package/dist/es2019/components/internal/utils.js +2 -0
  16. package/dist/es2019/components/stack.partial.js +18 -18
  17. package/dist/es2019/constants.js +3 -1
  18. package/dist/es2019/index.js +1 -1
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/components/box.js +12 -1
  21. package/dist/esm/components/inline.partial.js +47 -22
  22. package/dist/esm/components/internal/base-box.partial.js +100 -79
  23. package/dist/esm/components/internal/types.js +1 -0
  24. package/dist/esm/components/internal/utils.js +7 -0
  25. package/dist/esm/components/stack.partial.js +46 -21
  26. package/dist/esm/constants.js +3 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/components/box.d.ts +13 -6
  30. package/dist/types/components/inline.partial.d.ts +16 -18
  31. package/dist/types/components/internal/base-box.partial.d.ts +50 -51
  32. package/dist/types/components/internal/types.d.ts +6 -0
  33. package/dist/types/components/internal/utils.d.ts +3 -0
  34. package/dist/types/components/stack.partial.d.ts +16 -18
  35. package/dist/types/components/types.d.ts +49 -0
  36. package/dist/types/constants.d.ts +2 -0
  37. package/dist/types/index.d.ts +1 -1
  38. package/package.json +4 -2
  39. package/report.api.md +112 -79
  40. package/scripts/spacing-codegen-template.tsx +29 -24
  41. package/scripts/utils.tsx +4 -1
  42. package/tmp/api-report-tmp.d.ts +89 -78
@@ -1,11 +1,46 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _extends from "@babel/runtime/helpers/extends";
3
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  var _excluded = ["as", "className", "children", "color", "backgroundColor", "shadow", "borderStyle", "borderWidth", "borderRadius", "borderColor", "layer", "flex", "flexGrow", "flexShrink", "alignSelf", "overflow", "overflowInline", "overflowBlock", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "height", "width", "display", "position", "UNSAFE_style", "testId"];
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
7
  /** @jsx jsx */
6
8
  import { forwardRef } from 'react';
7
9
  import { css, jsx } from '@emotion/react';
8
- import { LAYERS } from '../../constants';
10
+ import invariant from 'tiny-invariant';
11
+ import { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST, LAYERS } from '../../constants';
12
+ import { BOX_RESPONSIVE_PROPS } from './types';
13
+ import { isResponsiveStyleProp, isStaticStyleProp } from './utils';
14
+ var responsiveRules = BOX_RESPONSIVE_PROPS.reduce(function (mapping, cssProperty) {
15
+ return Object.assign(mapping, _defineProperty({}, cssProperty, BREAKPOINTS_LIST.reduce(function (configs, breakpoint) {
16
+ var config = BREAKPOINTS_CONFIG[breakpoint];
17
+ return Object.assign(configs, _defineProperty({}, breakpoint, css(_defineProperty({}, "@media (min-width: ".concat(config.min, "px)"), _defineProperty({}, cssProperty, "var(--ds-box-responsive-".concat(cssProperty, "-").concat(breakpoint, ")"))))));
18
+ }, {
19
+ static: css(_defineProperty({}, cssProperty, "var(--ds-box-static-".concat(cssProperty, ")")))
20
+ })));
21
+ }, {});
22
+ var getResponsiveVars = function getResponsiveVars(propertyName, propertyValue, mapping) {
23
+ if (isResponsiveStyleProp(propertyValue)) {
24
+ return Object.keys(propertyValue).reduce(function (vars, breakpoint) {
25
+ return _objectSpread(_objectSpread({}, vars), {}, _defineProperty({}, "--ds-box-responsive-".concat(propertyName, "-").concat(breakpoint), mapping[propertyValue[breakpoint]]));
26
+ }, {});
27
+ } else if (isStaticStyleProp(propertyValue)) {
28
+ return _defineProperty({}, "--ds-box-static-".concat(propertyName), mapping[propertyValue]);
29
+ }
30
+ };
31
+ var getResponsiveStyles = function getResponsiveStyles(propertyName, propertyValue) {
32
+ invariant(typeof responsiveRules[propertyName] !== 'undefined', "Responsive rules for \"".concat(propertyName, "\" have not been statically defined."));
33
+ if (isResponsiveStyleProp(propertyValue)) {
34
+ return Object.keys(propertyValue).map(function (responsiveProp) {
35
+ return responsiveRules[propertyName][responsiveProp];
36
+ });
37
+ } else if (isStaticStyleProp(propertyValue)) {
38
+ return responsiveRules[propertyName].static;
39
+ }
40
+ };
41
+
42
+ // Without this type annotation on Box we don't get autocomplete for props due to forwardRef types
43
+
9
44
  /**
10
45
  * __Box__
11
46
  *
@@ -14,49 +49,50 @@ import { LAYERS } from '../../constants';
14
49
  *
15
50
  * @internal
16
51
  */
17
- export var BaseBox = /*#__PURE__*/forwardRef(function (_ref, ref) {
18
- var as = _ref.as,
19
- className = _ref.className,
20
- children = _ref.children,
21
- color = _ref.color,
22
- backgroundColor = _ref.backgroundColor,
23
- shadow = _ref.shadow,
24
- borderStyle = _ref.borderStyle,
25
- borderWidth = _ref.borderWidth,
26
- borderRadius = _ref.borderRadius,
27
- borderColor = _ref.borderColor,
28
- layer = _ref.layer,
29
- flex = _ref.flex,
30
- flexGrow = _ref.flexGrow,
31
- flexShrink = _ref.flexShrink,
32
- alignSelf = _ref.alignSelf,
33
- overflow = _ref.overflow,
34
- overflowInline = _ref.overflowInline,
35
- overflowBlock = _ref.overflowBlock,
36
- padding = _ref.padding,
37
- paddingBlock = _ref.paddingBlock,
38
- paddingBlockStart = _ref.paddingBlockStart,
39
- paddingBlockEnd = _ref.paddingBlockEnd,
40
- paddingInline = _ref.paddingInline,
41
- paddingInlineStart = _ref.paddingInlineStart,
42
- paddingInlineEnd = _ref.paddingInlineEnd,
43
- height = _ref.height,
44
- width = _ref.width,
45
- _ref$display = _ref.display,
46
- display = _ref$display === void 0 ? 'block' : _ref$display,
47
- _ref$position = _ref.position,
48
- position = _ref$position === void 0 ? 'static' : _ref$position,
49
- UNSAFE_style = _ref.UNSAFE_style,
50
- testId = _ref.testId,
51
- htmlAttributes = _objectWithoutProperties(_ref, _excluded);
52
+ export var BaseBox = /*#__PURE__*/forwardRef(function (_ref2, ref) {
53
+ var as = _ref2.as,
54
+ className = _ref2.className,
55
+ children = _ref2.children,
56
+ color = _ref2.color,
57
+ backgroundColor = _ref2.backgroundColor,
58
+ shadow = _ref2.shadow,
59
+ borderStyle = _ref2.borderStyle,
60
+ borderWidth = _ref2.borderWidth,
61
+ borderRadius = _ref2.borderRadius,
62
+ borderColor = _ref2.borderColor,
63
+ layer = _ref2.layer,
64
+ flex = _ref2.flex,
65
+ flexGrow = _ref2.flexGrow,
66
+ flexShrink = _ref2.flexShrink,
67
+ alignSelf = _ref2.alignSelf,
68
+ overflow = _ref2.overflow,
69
+ overflowInline = _ref2.overflowInline,
70
+ overflowBlock = _ref2.overflowBlock,
71
+ padding = _ref2.padding,
72
+ paddingBlock = _ref2.paddingBlock,
73
+ paddingBlockStart = _ref2.paddingBlockStart,
74
+ paddingBlockEnd = _ref2.paddingBlockEnd,
75
+ paddingInline = _ref2.paddingInline,
76
+ paddingInlineStart = _ref2.paddingInlineStart,
77
+ paddingInlineEnd = _ref2.paddingInlineEnd,
78
+ height = _ref2.height,
79
+ width = _ref2.width,
80
+ _ref2$display = _ref2.display,
81
+ display = _ref2$display === void 0 ? displayMap.block : _ref2$display,
82
+ _ref2$position = _ref2.position,
83
+ position = _ref2$position === void 0 ? 'static' : _ref2$position,
84
+ UNSAFE_style = _ref2.UNSAFE_style,
85
+ testId = _ref2.testId,
86
+ htmlAttributes = _objectWithoutProperties(_ref2, _excluded);
52
87
  var Component = as || 'div';
88
+ var inlineStyles = Object.assign({}, UNSAFE_style, getResponsiveVars('borderWidth', borderWidth, borderWidthMap), getResponsiveVars('display', display, displayMap), getResponsiveVars('padding', padding, paddingMap), getResponsiveVars('paddingBlock', paddingBlock, paddingMap), getResponsiveVars('paddingBlockStart', paddingBlockStart, paddingMap), getResponsiveVars('paddingBlockEnd', paddingBlockEnd, paddingMap), getResponsiveVars('paddingInline', paddingInline, paddingMap), getResponsiveVars('paddingInlineStart', paddingInlineStart, paddingMap), getResponsiveVars('paddingInlineEnd', paddingInlineEnd, paddingMap));
53
89
  var node = jsx(Component, _extends({
54
- style: UNSAFE_style,
90
+ style: inlineStyles,
55
91
  ref: ref
56
92
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
57
93
  }, htmlAttributes, {
58
94
  className: className,
59
- css: [baseStyles, display && displayMap[display], backgroundColor && backgroundColorMap[backgroundColor], color && textColorMap[color], flex && flexMap[flex], flexGrow && flexGrowMap[flexGrow], flexShrink && flexShrinkMap[flexShrink], alignSelf && alignSelfMap[alignSelf], overflow && overflowMap[overflow], overflowInline && overflowInlineMap[overflowInline], overflowBlock && overflowBlockMap[overflowBlock], padding && paddingMap.padding[padding], position && positionMap[position], paddingBlock && paddingMap.paddingBlock[paddingBlock], paddingBlockStart && paddingMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && paddingMap.paddingBlockEnd[paddingBlockEnd], paddingInline && paddingMap.paddingInline[paddingInline], paddingInlineStart && paddingMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && paddingMap.paddingInlineEnd[paddingInlineEnd], borderColor && borderColorMap[borderColor], borderStyle && borderStyleMap[borderStyle], borderWidth && borderWidthMap[borderWidth], borderRadius && borderRadiusMap[borderRadius], shadow && shadowMap[shadow], layer && layerMap[layer], overflow && overflowMap[overflow], width && widthMap[width], height && heightMap[height]],
95
+ css: [baseStyles].concat([getResponsiveStyles('borderWidth', borderWidth), getResponsiveStyles('display', display), getResponsiveStyles('padding', padding), getResponsiveStyles('paddingBlock', paddingBlock), getResponsiveStyles('paddingBlockStart', paddingBlockStart), getResponsiveStyles('paddingBlockEnd', paddingBlockEnd), getResponsiveStyles('paddingInline', paddingInline), getResponsiveStyles('paddingInlineStart', paddingInlineStart), getResponsiveStyles('paddingInlineEnd', paddingInlineEnd)], [backgroundColor && backgroundColorMap[backgroundColor], borderColor && borderColorMap[borderColor], color && textColorMap[color], flex && flexMap[flex], flexGrow && flexGrowMap[flexGrow], flexShrink && flexShrinkMap[flexShrink], alignSelf && alignSelfMap[alignSelf], overflow && overflowMap[overflow], overflowInline && overflowInlineMap[overflowInline], overflowBlock && overflowBlockMap[overflowBlock], position && positionMap[position], borderStyle && borderStyleMap[borderStyle], borderRadius && borderRadiusMap[borderRadius], shadow && shadowMap[shadow], layer && layerMap[layer], overflow && overflowMap[overflow], width && widthMap[width], height && heightMap[height]]),
60
96
  "data-testid": testId
61
97
  }), children);
62
98
  return node;
@@ -75,12 +111,9 @@ var borderStyleMap = {
75
111
  })
76
112
  };
77
113
  var borderWidthMap = {
78
- 'size.050': css({
79
- borderWidth: "var(--ds-width-050, 1px)"
80
- }),
81
- 'size.100': css({
82
- borderWidth: "var(--ds-width-100, 2px)"
83
- })
114
+ 'size.0': "var(--ds-width-0, 0)",
115
+ 'size.050': "var(--ds-width-050, 1px)",
116
+ 'size.100': "var(--ds-width-100, 2px)"
84
117
  };
85
118
  var borderRadiusMap = {
86
119
  'radius.100': css({
@@ -138,21 +171,11 @@ var alignSelfMap = {
138
171
  })
139
172
  };
140
173
  var displayMap = {
141
- block: css({
142
- display: 'block'
143
- }),
144
- inline: css({
145
- display: 'inline'
146
- }),
147
- flex: css({
148
- display: 'flex'
149
- }),
150
- 'inline-flex': css({
151
- display: 'inline-flex'
152
- }),
153
- 'inline-block': css({
154
- display: 'inline-block'
155
- })
174
+ block: 'block',
175
+ inline: 'inline',
176
+ flex: 'flex',
177
+ 'inline-flex': 'inline-flex',
178
+ 'inline-block': 'inline-block'
156
179
  };
157
180
  var positionMap = {
158
181
  absolute: css({
@@ -367,30 +390,28 @@ var maxHeightMap = {
367
390
 
368
391
  /**
369
392
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
370
- * @codegen <<SignedSource::6da0ceaa2c227230e3a93bc724ff8648>>
393
+ * @codegen <<SignedSource::84fd352b0e6509d380a0dcf8ad023ca2>>
371
394
  * @codegenId spacing
372
395
  * @codegenCommand yarn codegen-styles
373
396
  * @codegenParams ["padding"]
374
397
  * @codegenDependency ../../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
375
398
  */
376
- var paddingMap = Object.fromEntries(['padding', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd'].map(function (property) {
377
- return [property, {
378
- 'space.0': css(_defineProperty({}, property, "var(--ds-space-0, 0px)")),
379
- 'space.025': css(_defineProperty({}, property, "var(--ds-space-025, 2px)")),
380
- 'space.050': css(_defineProperty({}, property, "var(--ds-space-050, 4px)")),
381
- 'space.075': css(_defineProperty({}, property, "var(--ds-space-075, 6px)")),
382
- 'space.100': css(_defineProperty({}, property, "var(--ds-space-100, 8px)")),
383
- 'space.150': css(_defineProperty({}, property, "var(--ds-space-150, 12px)")),
384
- 'space.200': css(_defineProperty({}, property, "var(--ds-space-200, 16px)")),
385
- 'space.250': css(_defineProperty({}, property, "var(--ds-space-250, 20px)")),
386
- 'space.300': css(_defineProperty({}, property, "var(--ds-space-300, 24px)")),
387
- 'space.400': css(_defineProperty({}, property, "var(--ds-space-400, 32px)")),
388
- 'space.500': css(_defineProperty({}, property, "var(--ds-space-500, 40px)")),
389
- 'space.600': css(_defineProperty({}, property, "var(--ds-space-600, 48px)")),
390
- 'space.800': css(_defineProperty({}, property, "var(--ds-space-800, 64px)")),
391
- 'space.1000': css(_defineProperty({}, property, "var(--ds-space-1000, 80px)"))
392
- }];
393
- }));
399
+ var paddingMap = {
400
+ 'space.0': "var(--ds-space-0, 0px)",
401
+ 'space.025': "var(--ds-space-025, 2px)",
402
+ 'space.050': "var(--ds-space-050, 4px)",
403
+ 'space.075': "var(--ds-space-075, 6px)",
404
+ 'space.100': "var(--ds-space-100, 8px)",
405
+ 'space.150': "var(--ds-space-150, 12px)",
406
+ 'space.200': "var(--ds-space-200, 16px)",
407
+ 'space.250': "var(--ds-space-250, 20px)",
408
+ 'space.300': "var(--ds-space-300, 24px)",
409
+ 'space.400': "var(--ds-space-400, 32px)",
410
+ 'space.500': "var(--ds-space-500, 40px)",
411
+ 'space.600': "var(--ds-space-600, 48px)",
412
+ 'space.800': "var(--ds-space-800, 64px)",
413
+ 'space.1000': "var(--ds-space-1000, 80px)"
414
+ };
394
415
  /**
395
416
  * @codegenEnd
396
417
  */
@@ -0,0 +1 @@
1
+ export var BOX_RESPONSIVE_PROPS = ['borderWidth', 'display', 'padding', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd'];
@@ -0,0 +1,7 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ export var isResponsiveStyleProp = function isResponsiveStyleProp(propertyValue) {
3
+ return _typeof(propertyValue) === 'object';
4
+ };
5
+ export var isStaticStyleProp = function isStaticStyleProp(propertyValue) {
6
+ return typeof propertyValue === 'string';
7
+ };
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  /** @jsx jsx */
3
2
  import { forwardRef, memo } from 'react';
4
3
  import { css, jsx } from '@emotion/react';
@@ -38,30 +37,56 @@ var flexGrowMap = {
38
37
 
39
38
  /**
40
39
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
41
- * @codegen <<SignedSource::0e30ffcc6aef7932f9d8ff2543327236>>
40
+ * @codegen <<SignedSource::41d7002b7f69aa44d0d8598e07a1afc6>>
42
41
  * @codegenId spacing
43
42
  * @codegenCommand yarn codegen-styles
44
43
  * @codegenParams ["space"]
45
44
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
46
45
  */
47
- var spaceMap = Object.fromEntries(['gap'].map(function (property) {
48
- return [property, {
49
- '0': css(_defineProperty({}, property, "var(--ds-space-0, 0px)")),
50
- '025': css(_defineProperty({}, property, "var(--ds-space-025, 2px)")),
51
- '050': css(_defineProperty({}, property, "var(--ds-space-050, 4px)")),
52
- '075': css(_defineProperty({}, property, "var(--ds-space-075, 6px)")),
53
- '100': css(_defineProperty({}, property, "var(--ds-space-100, 8px)")),
54
- '150': css(_defineProperty({}, property, "var(--ds-space-150, 12px)")),
55
- '200': css(_defineProperty({}, property, "var(--ds-space-200, 16px)")),
56
- '250': css(_defineProperty({}, property, "var(--ds-space-250, 20px)")),
57
- '300': css(_defineProperty({}, property, "var(--ds-space-300, 24px)")),
58
- '400': css(_defineProperty({}, property, "var(--ds-space-400, 32px)")),
59
- '500': css(_defineProperty({}, property, "var(--ds-space-500, 40px)")),
60
- '600': css(_defineProperty({}, property, "var(--ds-space-600, 48px)")),
61
- '800': css(_defineProperty({}, property, "var(--ds-space-800, 64px)")),
62
- '1000': css(_defineProperty({}, property, "var(--ds-space-1000, 80px)"))
63
- }];
64
- }));
46
+ var spaceMap = {
47
+ '0': css({
48
+ gap: "var(--ds-space-0, 0px)"
49
+ }),
50
+ '025': css({
51
+ gap: "var(--ds-space-025, 2px)"
52
+ }),
53
+ '050': css({
54
+ gap: "var(--ds-space-050, 4px)"
55
+ }),
56
+ '075': css({
57
+ gap: "var(--ds-space-075, 6px)"
58
+ }),
59
+ '100': css({
60
+ gap: "var(--ds-space-100, 8px)"
61
+ }),
62
+ '150': css({
63
+ gap: "var(--ds-space-150, 12px)"
64
+ }),
65
+ '200': css({
66
+ gap: "var(--ds-space-200, 16px)"
67
+ }),
68
+ '250': css({
69
+ gap: "var(--ds-space-250, 20px)"
70
+ }),
71
+ '300': css({
72
+ gap: "var(--ds-space-300, 24px)"
73
+ }),
74
+ '400': css({
75
+ gap: "var(--ds-space-400, 32px)"
76
+ }),
77
+ '500': css({
78
+ gap: "var(--ds-space-500, 40px)"
79
+ }),
80
+ '600': css({
81
+ gap: "var(--ds-space-600, 48px)"
82
+ }),
83
+ '800': css({
84
+ gap: "var(--ds-space-800, 64px)"
85
+ }),
86
+ '1000': css({
87
+ gap: "var(--ds-space-1000, 80px)"
88
+ })
89
+ };
65
90
  /**
66
91
  * @codegenEnd
67
92
  */
@@ -96,7 +121,7 @@ var Stack = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
96
121
  testId = _ref.testId;
97
122
  var justifyContent = spread || alignBlock;
98
123
  return jsx("div", {
99
- css: [baseStyles, space && spaceMap.gap[space], alignItems && alignItemsMap[alignItems], grow && flexGrowMap[grow], justifyContent && justifyContentMap[justifyContent]],
124
+ css: [baseStyles, space && spaceMap[space], alignItems && alignItemsMap[alignItems], grow && flexGrowMap[grow], justifyContent && justifyContentMap[justifyContent]],
100
125
  "data-testid": testId,
101
126
  ref: ref
102
127
  }, children);
@@ -1,3 +1,4 @@
1
+ import { UNSAFE_Breakpoint as Breakpoint, UNSAFE_BreakpointConfig as BreakpointConfig, UNSAFE_BREAKPOINTS_CONFIG as BREAKPOINTS_CONFIG, UNSAFE_BREAKPOINTS_LIST as BREAKPOINTS_LIST } from '@atlaskit/ds-explorations';
1
2
  export var LAYERS = {
2
3
  card: 100,
3
4
  navigation: 200,
@@ -8,4 +9,5 @@ export var LAYERS = {
8
9
  flag: 600,
9
10
  spotlight: 700,
10
11
  tooltip: 800
11
- };
12
+ };
13
+ export { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST };
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { Box } from './components/box';
1
+ export { default as Box } from './components/box';
2
2
  export { default as Inline } from './components/inline.partial';
3
3
  export { default as Stack } from './components/stack.partial';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,10 +1,17 @@
1
1
  import { ElementType, FC, ReactElement } from 'react';
2
2
  import { BaseBoxProps } from './internal/base-box.partial';
3
- import { CustomStyles } from './types';
4
- declare type BoxPropsBase = {
5
- customStyles?: CustomStyles;
6
- };
7
- export declare type BoxProps<T extends ElementType = 'div'> = Omit<BaseBoxProps<T>, 'className' | 'UNSAFE_style'> & BoxPropsBase;
3
+ import { BoxResponsiveProp } from './internal/types';
4
+ import { PublicBoxPropsBase } from './types';
5
+ export declare type BoxProps<T extends ElementType = 'div'> = Omit<BaseBoxProps<T>, 'className' | 'UNSAFE_style' | BoxResponsiveProp> & PublicBoxPropsBase;
8
6
  declare type BoxComponent<T extends ElementType = 'div'> = (<T extends ElementType = 'div'>(props: BoxProps<T>) => ReactElement | null) & FC<BoxProps<T>>;
7
+ /**
8
+ * __Box__
9
+ *
10
+ * A box {description}.
11
+ *
12
+ * - [Examples](https://atlassian.design/components/{packageName}/examples)
13
+ * - [Code](https://atlassian.design/components/{packageName}/code)
14
+ * - [Usage](https://atlassian.design/components/{packageName}/usage)
15
+ */
9
16
  declare const Box: BoxComponent;
10
- export { Box };
17
+ export default Box;
@@ -44,31 +44,29 @@ export declare type Spread = 'space-between';
44
44
  export declare type Grow = 'hug' | 'fill';
45
45
  /**
46
46
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
47
- * @codegen <<SignedSource::0e30ffcc6aef7932f9d8ff2543327236>>
47
+ * @codegen <<SignedSource::41d7002b7f69aa44d0d8598e07a1afc6>>
48
48
  * @codegenId spacing
49
49
  * @codegenCommand yarn codegen-styles
50
50
  * @codegenParams ["space"]
51
51
  * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
52
52
  */
53
53
  declare const spaceMap: {
54
- [k: string]: {
55
- readonly '0': import("@emotion/react").SerializedStyles;
56
- readonly '025': import("@emotion/react").SerializedStyles;
57
- readonly '050': import("@emotion/react").SerializedStyles;
58
- readonly '075': import("@emotion/react").SerializedStyles;
59
- readonly '100': import("@emotion/react").SerializedStyles;
60
- readonly '150': import("@emotion/react").SerializedStyles;
61
- readonly '200': import("@emotion/react").SerializedStyles;
62
- readonly '250': import("@emotion/react").SerializedStyles;
63
- readonly '300': import("@emotion/react").SerializedStyles;
64
- readonly '400': import("@emotion/react").SerializedStyles;
65
- readonly '500': import("@emotion/react").SerializedStyles;
66
- readonly '600': import("@emotion/react").SerializedStyles;
67
- readonly '800': import("@emotion/react").SerializedStyles;
68
- readonly '1000': import("@emotion/react").SerializedStyles;
69
- };
54
+ readonly '0': import("@emotion/react").SerializedStyles;
55
+ readonly '025': import("@emotion/react").SerializedStyles;
56
+ readonly '050': import("@emotion/react").SerializedStyles;
57
+ readonly '075': import("@emotion/react").SerializedStyles;
58
+ readonly '100': import("@emotion/react").SerializedStyles;
59
+ readonly '150': import("@emotion/react").SerializedStyles;
60
+ readonly '200': import("@emotion/react").SerializedStyles;
61
+ readonly '250': import("@emotion/react").SerializedStyles;
62
+ readonly '300': import("@emotion/react").SerializedStyles;
63
+ readonly '400': import("@emotion/react").SerializedStyles;
64
+ readonly '500': import("@emotion/react").SerializedStyles;
65
+ readonly '600': import("@emotion/react").SerializedStyles;
66
+ readonly '800': import("@emotion/react").SerializedStyles;
67
+ readonly '1000': import("@emotion/react").SerializedStyles;
70
68
  };
71
- export declare type Space = keyof typeof spaceMap.gap;
69
+ export declare type Space = keyof typeof spaceMap;
72
70
  /**
73
71
  * __Inline__
74
72
  *
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, FC, ReactElement, ReactNode } from 'react';
3
- import { Layer } from '../../constants';
3
+ import { Breakpoint, Layer } from '../../constants';
4
4
  import type { BasePrimitiveProps } from '../types';
5
5
  export declare type BaseBoxProps<T extends ElementType = 'div'> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className' | 'style'> & BasePrimitiveProps & BaseBoxPropsFoundation<T>;
6
6
  declare type BaseBoxPropsFoundation<T extends ElementType> = {
@@ -43,7 +43,7 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
43
43
  /**
44
44
  * Defines border width.
45
45
  */
46
- borderWidth?: BorderWidth;
46
+ borderWidth?: BorderWidth | Partial<Record<Breakpoint, BorderWidth>>;
47
47
  /**
48
48
  * Token representing border color with a fallback.
49
49
  */
@@ -89,42 +89,42 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
89
89
  */
90
90
  overflowBlock?: OverflowBlock;
91
91
  /**
92
- * Shorthand for `paddingBlock` and `paddingInline` together.
92
+ * Tokens representing CSS shorthand for `paddingBlock` and `paddingInline` together.
93
93
  *
94
94
  * @see paddingBlock
95
95
  * @see paddingInline
96
96
  */
97
- padding?: Padding;
97
+ padding?: Padding | Partial<Record<Breakpoint, Padding>>;
98
98
  /**
99
- * Token representing CSS shorthand `paddingBlock`.
99
+ * Tokens representing CSS shorthand `paddingBlock`.
100
100
  *
101
101
  * @see paddingBlockStart
102
102
  * @see paddingBlockEnd
103
103
  */
104
- paddingBlock?: PaddingBlock;
104
+ paddingBlock?: PaddingBlock | Partial<Record<Breakpoint, PaddingBlock>>;
105
105
  /**
106
- * Token representing CSS `paddingBlockStart`.
106
+ * Tokens representing CSS `paddingBlockStart`.
107
107
  */
108
- paddingBlockStart?: PaddingBlockStart;
108
+ paddingBlockStart?: PaddingBlockStart | Partial<Record<Breakpoint, PaddingBlockStart>>;
109
109
  /**
110
- * Token representing CSS `paddingBlockEnd`.
110
+ * Tokens representing CSS `paddingBlockEnd`.
111
111
  */
112
- paddingBlockEnd?: PaddingBlockEnd;
112
+ paddingBlockEnd?: PaddingBlockEnd | Partial<Record<Breakpoint, PaddingBlockEnd>>;
113
113
  /**
114
- * Token representing CSS shorthand `paddingInline`.
114
+ * Tokens representing CSS shorthand `paddingInline`.
115
115
  *
116
116
  * @see paddingInlineStart
117
117
  * @see paddingInlineEnd
118
118
  */
119
- paddingInline?: PaddingInline;
119
+ paddingInline?: PaddingInline | Partial<Record<Breakpoint, PaddingInline>>;
120
120
  /**
121
- * Token representing CSS `paddingInlineStart`.
121
+ * Tokens representing CSS `paddingInlineStart`.
122
122
  */
123
- paddingInlineStart?: PaddingInlineStart;
123
+ paddingInlineStart?: PaddingInlineStart | Partial<Record<Breakpoint, PaddingInlineStart>>;
124
124
  /**
125
- * Token representing CSS `paddingInlineEnd`.
125
+ * Tokens representing CSS `paddingInlineEnd`.
126
126
  */
127
- paddingInlineEnd?: PaddingInlineEnd;
127
+ paddingInlineEnd?: PaddingInlineEnd | Partial<Record<Breakpoint, PaddingInlineEnd>>;
128
128
  /**
129
129
  * Token representing width.
130
130
  * @experimental The existing tokens will be replaced to better reflect dimensions.
@@ -136,9 +136,9 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
136
136
  */
137
137
  height?: Height;
138
138
  /**
139
- * Defines display type and layout. Defaults to `flex`.
139
+ * Defines display type and layout. Defaults to `block`.
140
140
  */
141
- display?: Display;
141
+ display?: Display | Partial<Record<Breakpoint, Display>>;
142
142
  /**
143
143
  * CSS position property.
144
144
  */
@@ -161,10 +161,11 @@ declare const borderStyleMap: {
161
161
  readonly none: import("@emotion/react").SerializedStyles;
162
162
  readonly solid: import("@emotion/react").SerializedStyles;
163
163
  };
164
- declare type BorderWidth = keyof typeof borderWidthMap;
164
+ export declare type BorderWidth = keyof typeof borderWidthMap;
165
165
  declare const borderWidthMap: {
166
- readonly 'size.050': import("@emotion/react").SerializedStyles;
167
- readonly 'size.100': import("@emotion/react").SerializedStyles;
166
+ readonly 'size.0': "var(--ds-width-0)";
167
+ readonly 'size.050': "var(--ds-width-050)";
168
+ readonly 'size.100': "var(--ds-width-100)";
168
169
  };
169
170
  declare type BorderRadius = keyof typeof borderRadiusMap;
170
171
  declare const borderRadiusMap: {
@@ -196,13 +197,13 @@ declare const alignSelfMap: {
196
197
  readonly end: import("@emotion/react").SerializedStyles;
197
198
  readonly baseline: import("@emotion/react").SerializedStyles;
198
199
  };
199
- declare type Display = keyof typeof displayMap;
200
+ export declare type Display = keyof typeof displayMap;
200
201
  declare const displayMap: {
201
- readonly block: import("@emotion/react").SerializedStyles;
202
- readonly inline: import("@emotion/react").SerializedStyles;
203
- readonly flex: import("@emotion/react").SerializedStyles;
204
- readonly 'inline-flex': import("@emotion/react").SerializedStyles;
205
- readonly 'inline-block': import("@emotion/react").SerializedStyles;
202
+ readonly block: "block";
203
+ readonly inline: "inline";
204
+ readonly flex: "flex";
205
+ readonly 'inline-flex': "inline-flex";
206
+ readonly 'inline-block': "inline-block";
206
207
  };
207
208
  declare type Position = keyof typeof positionMap;
208
209
  declare const positionMap: {
@@ -304,37 +305,35 @@ export declare type MaxHeight = keyof typeof maxHeightMap;
304
305
  */
305
306
  /**
306
307
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
307
- * @codegen <<SignedSource::6da0ceaa2c227230e3a93bc724ff8648>>
308
+ * @codegen <<SignedSource::84fd352b0e6509d380a0dcf8ad023ca2>>
308
309
  * @codegenId spacing
309
310
  * @codegenCommand yarn codegen-styles
310
311
  * @codegenParams ["padding"]
311
312
  * @codegenDependency ../../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::167d3b69b159ae33e74d4ea5ab7eade6>>
312
313
  */
313
314
  declare const paddingMap: {
314
- [k: string]: {
315
- readonly 'space.0': import("@emotion/react").SerializedStyles;
316
- readonly 'space.025': import("@emotion/react").SerializedStyles;
317
- readonly 'space.050': import("@emotion/react").SerializedStyles;
318
- readonly 'space.075': import("@emotion/react").SerializedStyles;
319
- readonly 'space.100': import("@emotion/react").SerializedStyles;
320
- readonly 'space.150': import("@emotion/react").SerializedStyles;
321
- readonly 'space.200': import("@emotion/react").SerializedStyles;
322
- readonly 'space.250': import("@emotion/react").SerializedStyles;
323
- readonly 'space.300': import("@emotion/react").SerializedStyles;
324
- readonly 'space.400': import("@emotion/react").SerializedStyles;
325
- readonly 'space.500': import("@emotion/react").SerializedStyles;
326
- readonly 'space.600': import("@emotion/react").SerializedStyles;
327
- readonly 'space.800': import("@emotion/react").SerializedStyles;
328
- readonly 'space.1000': import("@emotion/react").SerializedStyles;
329
- };
315
+ readonly 'space.0': "var(--ds-space-0)";
316
+ readonly 'space.025': "var(--ds-space-025)";
317
+ readonly 'space.050': "var(--ds-space-050)";
318
+ readonly 'space.075': "var(--ds-space-075)";
319
+ readonly 'space.100': "var(--ds-space-100)";
320
+ readonly 'space.150': "var(--ds-space-150)";
321
+ readonly 'space.200': "var(--ds-space-200)";
322
+ readonly 'space.250': "var(--ds-space-250)";
323
+ readonly 'space.300': "var(--ds-space-300)";
324
+ readonly 'space.400': "var(--ds-space-400)";
325
+ readonly 'space.500': "var(--ds-space-500)";
326
+ readonly 'space.600': "var(--ds-space-600)";
327
+ readonly 'space.800': "var(--ds-space-800)";
328
+ readonly 'space.1000': "var(--ds-space-1000)";
330
329
  };
331
- export declare type Padding = keyof typeof paddingMap.padding;
332
- export declare type PaddingBlock = keyof typeof paddingMap.paddingBlock;
333
- export declare type PaddingBlockStart = keyof typeof paddingMap.paddingBlockStart;
334
- export declare type PaddingBlockEnd = keyof typeof paddingMap.paddingBlockEnd;
335
- export declare type PaddingInline = keyof typeof paddingMap.paddingInline;
336
- export declare type PaddingInlineStart = keyof typeof paddingMap.paddingInlineStart;
337
- export declare type PaddingInlineEnd = keyof typeof paddingMap.paddingInlineEnd;
330
+ export declare type Padding = keyof typeof paddingMap;
331
+ export declare type PaddingBlock = keyof typeof paddingMap;
332
+ export declare type PaddingBlockStart = keyof typeof paddingMap;
333
+ export declare type PaddingBlockEnd = keyof typeof paddingMap;
334
+ export declare type PaddingInline = keyof typeof paddingMap;
335
+ export declare type PaddingInlineStart = keyof typeof paddingMap;
336
+ export declare type PaddingInlineEnd = keyof typeof paddingMap;
338
337
  /**
339
338
  * @codegenEnd
340
339
  */
@@ -0,0 +1,6 @@
1
+ import { SerializedStyles } from '@emotion/react';
2
+ import { Breakpoint } from '../../constants';
3
+ export declare const BOX_RESPONSIVE_PROPS: readonly ["borderWidth", "display", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd"];
4
+ export declare type BoxResponsiveProp = typeof BOX_RESPONSIVE_PROPS[number];
5
+ export declare type BreakpointIndexedStyle = Record<Breakpoint | 'static', SerializedStyles>;
6
+ export declare type GenericPropertyValue = string | Partial<Record<Breakpoint, string>> | undefined;
@@ -0,0 +1,3 @@
1
+ import { GenericPropertyValue } from './types';
2
+ export declare const isResponsiveStyleProp: (propertyValue: GenericPropertyValue) => propertyValue is object;
3
+ export declare const isStaticStyleProp: (propertyValue: GenericPropertyValue) => propertyValue is string;