@atlaskit/primitives 0.3.0 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`114d6a73f72`](https://bitbucket.org/atlassian/atlassian-frontend/commits/114d6a73f72) - Cleanup the experimental responsive box utilizing our responsive helpers.
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
@@ -12,18 +12,18 @@ var _react = require("react");
12
12
  var _react2 = require("@emotion/react");
13
13
  var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
14
14
  var _constants = require("../../constants");
15
+ var _responsive = require("../../helpers/responsive");
15
16
  var _types = require("./types");
16
17
  var _utils = require("./utils");
17
18
  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"];
18
19
  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; }
19
20
  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) { (0, _defineProperty2.default)(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; }
20
21
  var responsiveRules = _types.BOX_RESPONSIVE_PROPS.reduce(function (mapping, cssProperty) {
21
- return Object.assign(mapping, (0, _defineProperty2.default)({}, cssProperty, _constants.BREAKPOINTS_LIST.reduce(function (configs, breakpoint) {
22
- var config = _constants.BREAKPOINTS_CONFIG[breakpoint];
23
- return Object.assign(configs, (0, _defineProperty2.default)({}, breakpoint, (0, _react2.css)((0, _defineProperty2.default)({}, "@media (min-width: ".concat(config.min, "px)"), (0, _defineProperty2.default)({}, cssProperty, "var(--ds-box-responsive-".concat(cssProperty, "-").concat(breakpoint, ")"))))));
24
- }, {
22
+ return Object.assign(mapping, (0, _defineProperty2.default)({}, cssProperty, _objectSpread({
25
23
  static: (0, _react2.css)((0, _defineProperty2.default)({}, cssProperty, "var(--ds-box-static-".concat(cssProperty, ")")))
26
- })));
24
+ }, (0, _responsive.UNSAFE_buildAboveMediaQueryCSS)(function (breakpoint) {
25
+ return (0, _defineProperty2.default)({}, cssProperty, "var(--ds-box-responsive-".concat(cssProperty, "-").concat(breakpoint, ")"));
26
+ }))));
27
27
  }, {});
28
28
  var getResponsiveVars = function getResponsiveVars(propertyName, propertyValue, mapping) {
29
29
  if ((0, _utils.isResponsiveStyleProp)(propertyValue)) {
@@ -37,8 +37,8 @@ var getResponsiveVars = function getResponsiveVars(propertyName, propertyValue,
37
37
  var getResponsiveStyles = function getResponsiveStyles(propertyName, propertyValue) {
38
38
  (0, _tinyInvariant.default)(typeof responsiveRules[propertyName] !== 'undefined', "Responsive rules for \"".concat(propertyName, "\" have not been statically defined."));
39
39
  if ((0, _utils.isResponsiveStyleProp)(propertyValue)) {
40
- return Object.keys(propertyValue).map(function (responsiveProp) {
41
- return responsiveRules[propertyName][responsiveProp];
40
+ return Object.keys(propertyValue).map(function (breakpoint) {
41
+ return responsiveRules[propertyName][breakpoint];
42
42
  });
43
43
  } else if ((0, _utils.isStaticStyleProp)(propertyValue)) {
44
44
  return responsiveRules[propertyName].static;
@@ -55,41 +55,41 @@ var getResponsiveStyles = function getResponsiveStyles(propertyName, propertyVal
55
55
  *
56
56
  * @internal
57
57
  */
58
- var BaseBox = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
59
- var as = _ref2.as,
60
- className = _ref2.className,
61
- children = _ref2.children,
62
- color = _ref2.color,
63
- backgroundColor = _ref2.backgroundColor,
64
- shadow = _ref2.shadow,
65
- borderStyle = _ref2.borderStyle,
66
- borderWidth = _ref2.borderWidth,
67
- borderRadius = _ref2.borderRadius,
68
- borderColor = _ref2.borderColor,
69
- layer = _ref2.layer,
70
- flex = _ref2.flex,
71
- flexGrow = _ref2.flexGrow,
72
- flexShrink = _ref2.flexShrink,
73
- alignSelf = _ref2.alignSelf,
74
- overflow = _ref2.overflow,
75
- overflowInline = _ref2.overflowInline,
76
- overflowBlock = _ref2.overflowBlock,
77
- padding = _ref2.padding,
78
- paddingBlock = _ref2.paddingBlock,
79
- paddingBlockStart = _ref2.paddingBlockStart,
80
- paddingBlockEnd = _ref2.paddingBlockEnd,
81
- paddingInline = _ref2.paddingInline,
82
- paddingInlineStart = _ref2.paddingInlineStart,
83
- paddingInlineEnd = _ref2.paddingInlineEnd,
84
- height = _ref2.height,
85
- width = _ref2.width,
86
- _ref2$display = _ref2.display,
87
- display = _ref2$display === void 0 ? displayMap.block : _ref2$display,
88
- _ref2$position = _ref2.position,
89
- position = _ref2$position === void 0 ? 'static' : _ref2$position,
90
- UNSAFE_style = _ref2.UNSAFE_style,
91
- testId = _ref2.testId,
92
- htmlAttributes = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
58
+ var BaseBox = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
59
+ var as = _ref3.as,
60
+ className = _ref3.className,
61
+ children = _ref3.children,
62
+ color = _ref3.color,
63
+ backgroundColor = _ref3.backgroundColor,
64
+ shadow = _ref3.shadow,
65
+ borderStyle = _ref3.borderStyle,
66
+ borderWidth = _ref3.borderWidth,
67
+ borderRadius = _ref3.borderRadius,
68
+ borderColor = _ref3.borderColor,
69
+ layer = _ref3.layer,
70
+ flex = _ref3.flex,
71
+ flexGrow = _ref3.flexGrow,
72
+ flexShrink = _ref3.flexShrink,
73
+ alignSelf = _ref3.alignSelf,
74
+ overflow = _ref3.overflow,
75
+ overflowInline = _ref3.overflowInline,
76
+ overflowBlock = _ref3.overflowBlock,
77
+ padding = _ref3.padding,
78
+ paddingBlock = _ref3.paddingBlock,
79
+ paddingBlockStart = _ref3.paddingBlockStart,
80
+ paddingBlockEnd = _ref3.paddingBlockEnd,
81
+ paddingInline = _ref3.paddingInline,
82
+ paddingInlineStart = _ref3.paddingInlineStart,
83
+ paddingInlineEnd = _ref3.paddingInlineEnd,
84
+ height = _ref3.height,
85
+ width = _ref3.width,
86
+ _ref3$display = _ref3.display,
87
+ display = _ref3$display === void 0 ? displayMap.block : _ref3$display,
88
+ _ref3$position = _ref3.position,
89
+ position = _ref3$position === void 0 ? 'static' : _ref3$position,
90
+ UNSAFE_style = _ref3.UNSAFE_style,
91
+ testId = _ref3.testId,
92
+ htmlAttributes = (0, _objectWithoutProperties2.default)(_ref3, _excluded);
93
93
  var Component = as || 'div';
94
94
  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));
95
95
  var node = (0, _react2.jsx)(Component, (0, _extends2.default)({
@@ -3,20 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "BREAKPOINTS_CONFIG", {
7
- enumerable: true,
8
- get: function get() {
9
- return _dsExplorations.UNSAFE_BREAKPOINTS_CONFIG;
10
- }
11
- });
12
- Object.defineProperty(exports, "BREAKPOINTS_LIST", {
13
- enumerable: true,
14
- get: function get() {
15
- return _dsExplorations.UNSAFE_BREAKPOINTS_LIST;
16
- }
17
- });
18
6
  exports.LAYERS = void 0;
19
- var _dsExplorations = require("@atlaskit/ds-explorations");
20
7
  var LAYERS = {
21
8
  card: 100,
22
9
  navigation: 200,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "sideEffects": false
5
5
  }
@@ -3,26 +3,20 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import { forwardRef } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import invariant from 'tiny-invariant';
6
- import { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST, LAYERS } from '../../constants';
6
+ import { LAYERS } from '../../constants';
7
+ import { UNSAFE_buildAboveMediaQueryCSS } from '../../helpers/responsive';
7
8
  import { BOX_RESPONSIVE_PROPS } from './types';
8
9
  import { isResponsiveStyleProp, isStaticStyleProp } from './utils';
9
10
  const responsiveRules = BOX_RESPONSIVE_PROPS.reduce((mapping, cssProperty) => {
10
11
  return Object.assign(mapping, {
11
- [cssProperty]: BREAKPOINTS_LIST.reduce((configs, breakpoint) => {
12
- const config = BREAKPOINTS_CONFIG[breakpoint];
13
- return Object.assign(configs, {
14
- [breakpoint]: css({
15
- // eslint-disable-next-line @repo/internal/styles/no-nested-styles
16
- [`@media (min-width: ${config.min}px)`]: {
17
- [cssProperty]: `var(--ds-box-responsive-${cssProperty}-${breakpoint})`
18
- }
19
- })
20
- });
21
- }, {
12
+ [cssProperty]: {
22
13
  static: css({
23
14
  [cssProperty]: `var(--ds-box-static-${cssProperty})`
24
- })
25
- })
15
+ }),
16
+ ...UNSAFE_buildAboveMediaQueryCSS(breakpoint => ({
17
+ [cssProperty]: `var(--ds-box-responsive-${cssProperty}-${breakpoint})`
18
+ }))
19
+ }
26
20
  });
27
21
  }, {});
28
22
  const getResponsiveVars = (propertyName, propertyValue, mapping) => {
@@ -40,7 +34,7 @@ const getResponsiveVars = (propertyName, propertyValue, mapping) => {
40
34
  const getResponsiveStyles = (propertyName, propertyValue) => {
41
35
  invariant(typeof responsiveRules[propertyName] !== 'undefined', `Responsive rules for "${propertyName}" have not been statically defined.`);
42
36
  if (isResponsiveStyleProp(propertyValue)) {
43
- return Object.keys(propertyValue).map(responsiveProp => responsiveRules[propertyName][responsiveProp]);
37
+ return Object.keys(propertyValue).map(breakpoint => responsiveRules[propertyName][breakpoint]);
44
38
  } else if (isStaticStyleProp(propertyValue)) {
45
39
  return responsiveRules[propertyName].static;
46
40
  }
@@ -1,4 +1,3 @@
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';
2
1
  export const LAYERS = {
3
2
  card: 100,
4
3
  navigation: 200,
@@ -9,5 +8,4 @@ export const LAYERS = {
9
8
  flag: 600,
10
9
  spotlight: 700,
11
10
  tooltip: 800
12
- };
13
- export { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST };
11
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "sideEffects": false
5
5
  }
@@ -8,16 +8,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
8
8
  import { forwardRef } from 'react';
9
9
  import { css, jsx } from '@emotion/react';
10
10
  import invariant from 'tiny-invariant';
11
- import { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST, LAYERS } from '../../constants';
11
+ import { LAYERS } from '../../constants';
12
+ import { UNSAFE_buildAboveMediaQueryCSS } from '../../helpers/responsive';
12
13
  import { BOX_RESPONSIVE_PROPS } from './types';
13
14
  import { isResponsiveStyleProp, isStaticStyleProp } from './utils';
14
15
  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
- }, {
16
+ return Object.assign(mapping, _defineProperty({}, cssProperty, _objectSpread({
19
17
  static: css(_defineProperty({}, cssProperty, "var(--ds-box-static-".concat(cssProperty, ")")))
20
- })));
18
+ }, UNSAFE_buildAboveMediaQueryCSS(function (breakpoint) {
19
+ return _defineProperty({}, cssProperty, "var(--ds-box-responsive-".concat(cssProperty, "-").concat(breakpoint, ")"));
20
+ }))));
21
21
  }, {});
22
22
  var getResponsiveVars = function getResponsiveVars(propertyName, propertyValue, mapping) {
23
23
  if (isResponsiveStyleProp(propertyValue)) {
@@ -31,8 +31,8 @@ var getResponsiveVars = function getResponsiveVars(propertyName, propertyValue,
31
31
  var getResponsiveStyles = function getResponsiveStyles(propertyName, propertyValue) {
32
32
  invariant(typeof responsiveRules[propertyName] !== 'undefined', "Responsive rules for \"".concat(propertyName, "\" have not been statically defined."));
33
33
  if (isResponsiveStyleProp(propertyValue)) {
34
- return Object.keys(propertyValue).map(function (responsiveProp) {
35
- return responsiveRules[propertyName][responsiveProp];
34
+ return Object.keys(propertyValue).map(function (breakpoint) {
35
+ return responsiveRules[propertyName][breakpoint];
36
36
  });
37
37
  } else if (isStaticStyleProp(propertyValue)) {
38
38
  return responsiveRules[propertyName].static;
@@ -49,41 +49,41 @@ var getResponsiveStyles = function getResponsiveStyles(propertyName, propertyVal
49
49
  *
50
50
  * @internal
51
51
  */
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
+ export var BaseBox = /*#__PURE__*/forwardRef(function (_ref3, ref) {
53
+ var as = _ref3.as,
54
+ className = _ref3.className,
55
+ children = _ref3.children,
56
+ color = _ref3.color,
57
+ backgroundColor = _ref3.backgroundColor,
58
+ shadow = _ref3.shadow,
59
+ borderStyle = _ref3.borderStyle,
60
+ borderWidth = _ref3.borderWidth,
61
+ borderRadius = _ref3.borderRadius,
62
+ borderColor = _ref3.borderColor,
63
+ layer = _ref3.layer,
64
+ flex = _ref3.flex,
65
+ flexGrow = _ref3.flexGrow,
66
+ flexShrink = _ref3.flexShrink,
67
+ alignSelf = _ref3.alignSelf,
68
+ overflow = _ref3.overflow,
69
+ overflowInline = _ref3.overflowInline,
70
+ overflowBlock = _ref3.overflowBlock,
71
+ padding = _ref3.padding,
72
+ paddingBlock = _ref3.paddingBlock,
73
+ paddingBlockStart = _ref3.paddingBlockStart,
74
+ paddingBlockEnd = _ref3.paddingBlockEnd,
75
+ paddingInline = _ref3.paddingInline,
76
+ paddingInlineStart = _ref3.paddingInlineStart,
77
+ paddingInlineEnd = _ref3.paddingInlineEnd,
78
+ height = _ref3.height,
79
+ width = _ref3.width,
80
+ _ref3$display = _ref3.display,
81
+ display = _ref3$display === void 0 ? displayMap.block : _ref3$display,
82
+ _ref3$position = _ref3.position,
83
+ position = _ref3$position === void 0 ? 'static' : _ref3$position,
84
+ UNSAFE_style = _ref3.UNSAFE_style,
85
+ testId = _ref3.testId,
86
+ htmlAttributes = _objectWithoutProperties(_ref3, _excluded);
87
87
  var Component = as || 'div';
88
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));
89
89
  var node = jsx(Component, _extends({
@@ -1,4 +1,3 @@
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';
2
1
  export var LAYERS = {
3
2
  card: 100,
4
3
  navigation: 200,
@@ -9,5 +8,4 @@ export var LAYERS = {
9
8
  flag: 600,
10
9
  spotlight: 700,
11
10
  tooltip: 800
12
- };
13
- export { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST };
11
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, FC, ReactElement, ReactNode } from 'react';
3
- import { Breakpoint, Layer } from '../../constants';
3
+ import { Layer } from '../../constants';
4
+ import { ResponsiveObject } from '../../helpers/responsive';
4
5
  import type { BasePrimitiveProps } from '../types';
5
6
  export declare type BaseBoxProps<T extends ElementType = 'div'> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className' | 'style'> & BasePrimitiveProps & BaseBoxPropsFoundation<T>;
6
7
  declare type BaseBoxPropsFoundation<T extends ElementType> = {
@@ -43,7 +44,7 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
43
44
  /**
44
45
  * Defines border width.
45
46
  */
46
- borderWidth?: BorderWidth | Partial<Record<Breakpoint, BorderWidth>>;
47
+ borderWidth?: BorderWidth | ResponsiveObject<BorderWidth>;
47
48
  /**
48
49
  * Token representing border color with a fallback.
49
50
  */
@@ -94,37 +95,37 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
94
95
  * @see paddingBlock
95
96
  * @see paddingInline
96
97
  */
97
- padding?: Padding | Partial<Record<Breakpoint, Padding>>;
98
+ padding?: Padding | ResponsiveObject<Padding>;
98
99
  /**
99
100
  * Tokens representing CSS shorthand `paddingBlock`.
100
101
  *
101
102
  * @see paddingBlockStart
102
103
  * @see paddingBlockEnd
103
104
  */
104
- paddingBlock?: PaddingBlock | Partial<Record<Breakpoint, PaddingBlock>>;
105
+ paddingBlock?: PaddingBlock | ResponsiveObject<PaddingBlock>;
105
106
  /**
106
107
  * Tokens representing CSS `paddingBlockStart`.
107
108
  */
108
- paddingBlockStart?: PaddingBlockStart | Partial<Record<Breakpoint, PaddingBlockStart>>;
109
+ paddingBlockStart?: PaddingBlockStart | ResponsiveObject<PaddingBlockStart>;
109
110
  /**
110
111
  * Tokens representing CSS `paddingBlockEnd`.
111
112
  */
112
- paddingBlockEnd?: PaddingBlockEnd | Partial<Record<Breakpoint, PaddingBlockEnd>>;
113
+ paddingBlockEnd?: PaddingBlockEnd | ResponsiveObject<PaddingBlockEnd>;
113
114
  /**
114
115
  * Tokens representing CSS shorthand `paddingInline`.
115
116
  *
116
117
  * @see paddingInlineStart
117
118
  * @see paddingInlineEnd
118
119
  */
119
- paddingInline?: PaddingInline | Partial<Record<Breakpoint, PaddingInline>>;
120
+ paddingInline?: PaddingInline | ResponsiveObject<PaddingInline>;
120
121
  /**
121
122
  * Tokens representing CSS `paddingInlineStart`.
122
123
  */
123
- paddingInlineStart?: PaddingInlineStart | Partial<Record<Breakpoint, PaddingInlineStart>>;
124
+ paddingInlineStart?: PaddingInlineStart | ResponsiveObject<PaddingInlineStart>;
124
125
  /**
125
126
  * Tokens representing CSS `paddingInlineEnd`.
126
127
  */
127
- paddingInlineEnd?: PaddingInlineEnd | Partial<Record<Breakpoint, PaddingInlineEnd>>;
128
+ paddingInlineEnd?: PaddingInlineEnd | ResponsiveObject<PaddingInlineEnd>;
128
129
  /**
129
130
  * Token representing width.
130
131
  * @experimental The existing tokens will be replaced to better reflect dimensions.
@@ -138,7 +139,7 @@ declare type BaseBoxPropsFoundation<T extends ElementType> = {
138
139
  /**
139
140
  * Defines display type and layout. Defaults to `block`.
140
141
  */
141
- display?: Display | Partial<Record<Breakpoint, Display>>;
142
+ display?: Display | ResponsiveObject<Display>;
142
143
  /**
143
144
  * CSS position property.
144
145
  */
@@ -1,6 +1,8 @@
1
1
  import { SerializedStyles } from '@emotion/react';
2
- import { Breakpoint } from '../../constants';
2
+ import { ResponsiveCSSObject, ResponsiveObject } from '../../helpers/responsive';
3
3
  export declare const BOX_RESPONSIVE_PROPS: readonly ["borderWidth", "display", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd"];
4
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;
5
+ export declare type StaticResponsiveCSSObject = ResponsiveCSSObject & {
6
+ static: SerializedStyles;
7
+ };
8
+ export declare type GenericPropertyValue = string | ResponsiveObject<string> | undefined;
@@ -1,4 +1,3 @@
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';
2
1
  export declare const LAYERS: {
3
2
  readonly card: 100;
4
3
  readonly navigation: 200;
@@ -11,4 +10,3 @@ export declare const LAYERS: {
11
10
  readonly tooltip: 800;
12
11
  };
13
12
  export declare type Layer = keyof typeof LAYERS;
14
- export { BREAKPOINTS_CONFIG, BREAKPOINTS_LIST, type Breakpoint, type BreakpointConfig, };
@@ -1,4 +1,4 @@
1
- import { css } from '@emotion/react';
1
+ import { SerializedStyles } from '@emotion/react';
2
2
  import { token } from '@atlaskit/tokens';
3
3
  /**
4
4
  * The breakpoints we have for responsiveness.
@@ -23,7 +23,7 @@ export declare type ResponsiveObject<T> = Partial<Record<Breakpoint, T>>;
23
23
  * return <div css={setMarginBreakpoints.map(breakpoint => marginMediaQueries[breakpoint])} />
24
24
  * ```
25
25
  */
26
- export declare type ResponsiveCSSObject = ResponsiveObject<ReturnType<typeof css>>;
26
+ export declare type ResponsiveCSSObject = ResponsiveObject<SerializedStyles>;
27
27
  /**
28
28
  * Our internal breakpoint config used to build media queries and define attributes for certain components.
29
29
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,7 +38,6 @@
38
38
  "./responsive": "./src/helpers/responsive/index.tsx"
39
39
  },
40
40
  "dependencies": {
41
- "@atlaskit/ds-explorations": "*",
42
41
  "@atlaskit/tokens": "^1.2.0",
43
42
  "@babel/runtime": "^7.0.0",
44
43
  "@emotion/react": "^11.7.1",
package/report.api.md CHANGED
@@ -26,7 +26,6 @@ import { ReactElement } from 'react';
26
26
  import { ReactNode } from 'react';
27
27
  import { RefAttributes } from 'react';
28
28
  import { SerializedStyles } from '@emotion/react';
29
- import { UNSAFE_Breakpoint } from '@atlaskit/ds-explorations';
30
29
 
31
30
  // @public (undocumented)
32
31
  type AlignBlock = 'baseline' | 'center' | 'end' | 'start';
@@ -138,7 +137,7 @@ type BaseBoxPropsFoundation<T extends ElementType> = {
138
137
  backgroundColor?: BackgroundColor;
139
138
  shadow?: Shadow;
140
139
  borderStyle?: BorderStyle;
141
- borderWidth?: BorderWidth | Partial<Record<UNSAFE_Breakpoint, BorderWidth>>;
140
+ borderWidth?: BorderWidth | ResponsiveObject<BorderWidth>;
142
141
  borderColor?: BorderColor;
143
142
  borderRadius?: BorderRadius;
144
143
  layer?: Layer;
@@ -149,28 +148,18 @@ type BaseBoxPropsFoundation<T extends ElementType> = {
149
148
  overflow?: Overflow;
150
149
  overflowInline?: OverflowInline;
151
150
  overflowBlock?: OverflowBlock;
152
- padding?: Padding | Partial<Record<UNSAFE_Breakpoint, Padding>>;
153
- paddingBlock?:
154
- | PaddingBlock
155
- | Partial<Record<UNSAFE_Breakpoint, PaddingBlock>>;
156
- paddingBlockStart?:
157
- | PaddingBlockStart
158
- | Partial<Record<UNSAFE_Breakpoint, PaddingBlockStart>>;
159
- paddingBlockEnd?:
160
- | PaddingBlockEnd
161
- | Partial<Record<UNSAFE_Breakpoint, PaddingBlockEnd>>;
162
- paddingInline?:
163
- | PaddingInline
164
- | Partial<Record<UNSAFE_Breakpoint, PaddingInline>>;
151
+ padding?: Padding | ResponsiveObject<Padding>;
152
+ paddingBlock?: PaddingBlock | ResponsiveObject<PaddingBlock>;
153
+ paddingBlockStart?: PaddingBlockStart | ResponsiveObject<PaddingBlockStart>;
154
+ paddingBlockEnd?: PaddingBlockEnd | ResponsiveObject<PaddingBlockEnd>;
155
+ paddingInline?: PaddingInline | ResponsiveObject<PaddingInline>;
165
156
  paddingInlineStart?:
166
157
  | PaddingInlineStart
167
- | Partial<Record<UNSAFE_Breakpoint, PaddingInlineStart>>;
168
- paddingInlineEnd?:
169
- | PaddingInlineEnd
170
- | Partial<Record<UNSAFE_Breakpoint, PaddingInlineEnd>>;
158
+ | ResponsiveObject<PaddingInlineStart>;
159
+ paddingInlineEnd?: PaddingInlineEnd | ResponsiveObject<PaddingInlineEnd>;
171
160
  width?: Width;
172
161
  height?: Height;
173
- display?: Display | Partial<Record<UNSAFE_Breakpoint, Display>>;
162
+ display?: Display | ResponsiveObject<Display>;
174
163
  position?: Position;
175
164
  ref?: ComponentPropsWithRef<T>['ref'];
176
165
  };
@@ -275,6 +264,9 @@ export type BoxProps<T extends ElementType = 'div'> = Omit<
275
264
  // @public (undocumented)
276
265
  type BoxResponsiveProp = typeof BOX_RESPONSIVE_PROPS[number];
277
266
 
267
+ // @public
268
+ type Breakpoint = 'lg' | 'md' | 'sm' | 'xl' | 'xs' | 'xxl' | 'xxs';
269
+
278
270
  // @public
279
271
  type CustomStyles = Pick<
280
272
  CSSProperties,
@@ -487,6 +479,9 @@ type PublicBoxPropsBase = {
487
479
  customStyles?: CustomStyles;
488
480
  };
489
481
 
482
+ // @public
483
+ type ResponsiveObject<T> = Partial<Record<Breakpoint, T>>;
484
+
490
485
  // @public (undocumented)
491
486
  type Shadow = keyof typeof shadowMap;
492
487
 
@@ -15,7 +15,6 @@ import { ReactElement } from 'react';
15
15
  import { ReactNode } from 'react';
16
16
  import { RefAttributes } from 'react';
17
17
  import { SerializedStyles } from '@emotion/react';
18
- import { UNSAFE_Breakpoint } from '@atlaskit/ds-explorations';
19
18
 
20
19
  // @public (undocumented)
21
20
  type AlignBlock = 'baseline' | 'center' | 'end' | 'start';
@@ -122,7 +121,7 @@ type BaseBoxPropsFoundation<T extends ElementType> = {
122
121
  backgroundColor?: BackgroundColor;
123
122
  shadow?: Shadow;
124
123
  borderStyle?: BorderStyle;
125
- borderWidth?: BorderWidth | Partial<Record<UNSAFE_Breakpoint, BorderWidth>>;
124
+ borderWidth?: BorderWidth | ResponsiveObject<BorderWidth>;
126
125
  borderColor?: BorderColor;
127
126
  borderRadius?: BorderRadius;
128
127
  layer?: Layer;
@@ -133,16 +132,16 @@ type BaseBoxPropsFoundation<T extends ElementType> = {
133
132
  overflow?: Overflow;
134
133
  overflowInline?: OverflowInline;
135
134
  overflowBlock?: OverflowBlock;
136
- padding?: Padding | Partial<Record<UNSAFE_Breakpoint, Padding>>;
137
- paddingBlock?: PaddingBlock | Partial<Record<UNSAFE_Breakpoint, PaddingBlock>>;
138
- paddingBlockStart?: PaddingBlockStart | Partial<Record<UNSAFE_Breakpoint, PaddingBlockStart>>;
139
- paddingBlockEnd?: PaddingBlockEnd | Partial<Record<UNSAFE_Breakpoint, PaddingBlockEnd>>;
140
- paddingInline?: PaddingInline | Partial<Record<UNSAFE_Breakpoint, PaddingInline>>;
141
- paddingInlineStart?: PaddingInlineStart | Partial<Record<UNSAFE_Breakpoint, PaddingInlineStart>>;
142
- paddingInlineEnd?: PaddingInlineEnd | Partial<Record<UNSAFE_Breakpoint, PaddingInlineEnd>>;
135
+ padding?: Padding | ResponsiveObject<Padding>;
136
+ paddingBlock?: PaddingBlock | ResponsiveObject<PaddingBlock>;
137
+ paddingBlockStart?: PaddingBlockStart | ResponsiveObject<PaddingBlockStart>;
138
+ paddingBlockEnd?: PaddingBlockEnd | ResponsiveObject<PaddingBlockEnd>;
139
+ paddingInline?: PaddingInline | ResponsiveObject<PaddingInline>;
140
+ paddingInlineStart?: PaddingInlineStart | ResponsiveObject<PaddingInlineStart>;
141
+ paddingInlineEnd?: PaddingInlineEnd | ResponsiveObject<PaddingInlineEnd>;
143
142
  width?: Width;
144
143
  height?: Height;
145
- display?: Display | Partial<Record<UNSAFE_Breakpoint, Display>>;
144
+ display?: Display | ResponsiveObject<Display>;
146
145
  position?: Position;
147
146
  ref?: ComponentPropsWithRef<T>['ref'];
148
147
  };
@@ -228,6 +227,9 @@ export type BoxProps<T extends ElementType = 'div'> = Omit<BaseBoxProps<T>, 'UNS
228
227
  // @public (undocumented)
229
228
  type BoxResponsiveProp = typeof BOX_RESPONSIVE_PROPS[number];
230
229
 
230
+ // @public
231
+ type Breakpoint = 'lg' | 'md' | 'sm' | 'xl' | 'xs' | 'xxl' | 'xxs';
232
+
231
233
  // @public
232
234
  type CustomStyles = Pick<CSSProperties, 'flex' | 'flexBasis' | 'float' | 'height' | 'insetBlockStart' | 'insetInlineEnd' | 'insetInlineStart' | 'margin' | 'marginBlock' | 'marginBlockEnd' | 'marginBlockStart' | 'marginInline' | 'marginInlineEnd' | 'marginInlineStart' | 'maxHeight' | 'maxWidth' | 'minHeight' | 'minWidth' | 'paddingBottom' | 'paddingLeft' | 'paddingRight' | 'paddingTop' | 'width'>;
233
235
 
@@ -413,6 +415,9 @@ type PublicBoxPropsBase = {
413
415
  customStyles?: CustomStyles;
414
416
  };
415
417
 
418
+ // @public
419
+ type ResponsiveObject<T> = Partial<Record<Breakpoint, T>>;
420
+
416
421
  // @public (undocumented)
417
422
  type Shadow = keyof typeof shadowMap;
418
423