@atlaskit/primitives 1.0.11 → 1.1.0

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,12 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`0116391a81e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0116391a81e) - - Support `xcss` in `Pressable`
8
+ - Remove dependency on `@atlaskit/focus-ring`
9
+
3
10
  ## 1.0.11
4
11
 
5
12
  ### Patch Changes
@@ -1,22 +1,44 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
8
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _react = require("react");
11
- var _react2 = require("@emotion/react");
12
- var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
13
- var _baseBox = _interopRequireDefault(require("./internal/base-box"));
14
- var _excluded = ["children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "isDisabled", "type", "testId"];
15
- /** @jsx jsx */
16
- var defaultStyles = (0, _react2.css)({
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _xcss = require("../xcss/xcss");
14
+ var _box = _interopRequireDefault(require("./box"));
15
+ var _excluded = ["children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "isDisabled", "type", "testId", "xcss"];
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ var defaultStyles = (0, _xcss.xcss)({
17
19
  cursor: 'pointer'
18
20
  });
19
21
 
22
+ // TODO: Duplicated FocusRing styles due to lack of `xcss` support
23
+ // and to prevent additional dependency
24
+ var baseFocusRingStyles = {
25
+ outlineColor: 'color.border.focused',
26
+ outlineWidth: 'border.width.outline',
27
+ outlineStyle: 'solid',
28
+ outlineOffset: 'space.025'
29
+ };
30
+ var focusRingStyles = (0, _xcss.xcss)({
31
+ ':focus-visible': baseFocusRingStyles,
32
+ '@supports not selector(*:focus-visible)': {
33
+ ':focus': baseFocusRingStyles
34
+ },
35
+ '@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
36
+ ':focus-visible': {
37
+ outline: '1px solid'
38
+ }
39
+ }
40
+ });
41
+
20
42
  /**
21
43
  * __UNSAFE_PRESSABLE__
22
44
  *
@@ -42,8 +64,12 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
42
64
  _ref$type = _ref.type,
43
65
  type = _ref$type === void 0 ? 'button' : _ref$type,
44
66
  testId = _ref.testId,
67
+ xcssStyles = _ref.xcss,
45
68
  htmlAttributes = (0, _objectWithoutProperties2.default)(_ref, _excluded);
46
- return (0, _react2.jsx)(_focusRing.default, null, (0, _react2.jsx)(_baseBox.default, (0, _extends2.default)({}, htmlAttributes, {
69
+ // Combine default styles with supplied styles. XCSS does not support deep nested arrays
70
+ var styles = [defaultStyles, focusRingStyles];
71
+ styles = Array.isArray(xcssStyles) ? [].concat((0, _toConsumableArray2.default)(styles), (0, _toConsumableArray2.default)(xcssStyles)) : [].concat((0, _toConsumableArray2.default)(styles), [xcssStyles]);
72
+ return /*#__PURE__*/_react.default.createElement(_box.default, (0, _extends2.default)({}, htmlAttributes, {
47
73
  ref: ref,
48
74
  testId: testId,
49
75
  type: type,
@@ -55,10 +81,12 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
55
81
  paddingInline: paddingInline,
56
82
  paddingInlineStart: paddingInlineStart,
57
83
  paddingInlineEnd: paddingInlineEnd,
58
- as: "button",
59
- css: defaultStyles,
84
+ as: "button"
85
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
86
+ ,
87
+ xcss: styles,
60
88
  disabled: isDisabled
61
- }), children));
89
+ }), children);
62
90
  });
63
91
  var _default = UNSAFE_PRESSABLE;
64
92
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.11",
3
+ "version": "1.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,13 +1,31 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- /** @jsx jsx */
3
- import { forwardRef } from 'react';
4
- import { css, jsx } from '@emotion/react';
5
- import FocusRing from '@atlaskit/focus-ring';
6
- import BaseBox from './internal/base-box';
7
- const defaultStyles = css({
2
+ import React, { forwardRef } from 'react';
3
+ import { xcss } from '../xcss/xcss';
4
+ import Box from './box';
5
+ const defaultStyles = xcss({
8
6
  cursor: 'pointer'
9
7
  });
10
8
 
9
+ // TODO: Duplicated FocusRing styles due to lack of `xcss` support
10
+ // and to prevent additional dependency
11
+ const baseFocusRingStyles = {
12
+ outlineColor: 'color.border.focused',
13
+ outlineWidth: 'border.width.outline',
14
+ outlineStyle: 'solid',
15
+ outlineOffset: 'space.025'
16
+ };
17
+ const focusRingStyles = xcss({
18
+ ':focus-visible': baseFocusRingStyles,
19
+ '@supports not selector(*:focus-visible)': {
20
+ ':focus': baseFocusRingStyles
21
+ },
22
+ '@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
23
+ ':focus-visible': {
24
+ outline: '1px solid'
25
+ }
26
+ }
27
+ });
28
+
11
29
  /**
12
30
  * __UNSAFE_PRESSABLE__
13
31
  *
@@ -32,9 +50,13 @@ const UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(({
32
50
  isDisabled,
33
51
  type = 'button',
34
52
  testId,
53
+ xcss: xcssStyles,
35
54
  ...htmlAttributes
36
55
  }, ref) => {
37
- return jsx(FocusRing, null, jsx(BaseBox, _extends({}, htmlAttributes, {
56
+ // Combine default styles with supplied styles. XCSS does not support deep nested arrays
57
+ let styles = [defaultStyles, focusRingStyles];
58
+ styles = Array.isArray(xcssStyles) ? [...styles, ...xcssStyles] : [...styles, xcssStyles];
59
+ return /*#__PURE__*/React.createElement(Box, _extends({}, htmlAttributes, {
38
60
  ref: ref,
39
61
  testId: testId,
40
62
  type: type,
@@ -46,9 +68,11 @@ const UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(({
46
68
  paddingInline: paddingInline,
47
69
  paddingInlineStart: paddingInlineStart,
48
70
  paddingInlineEnd: paddingInlineEnd,
49
- as: "button",
50
- css: defaultStyles,
71
+ as: "button"
72
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
73
+ ,
74
+ xcss: styles,
51
75
  disabled: isDisabled
52
- }), children));
76
+ }), children);
53
77
  });
54
78
  export default UNSAFE_PRESSABLE;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.11",
3
+ "version": "1.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,15 +1,34 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "isDisabled", "type", "testId"];
4
- /** @jsx jsx */
5
- import { forwardRef } from 'react';
6
- import { css, jsx } from '@emotion/react';
7
- import FocusRing from '@atlaskit/focus-ring';
8
- import BaseBox from './internal/base-box';
9
- var defaultStyles = css({
4
+ var _excluded = ["children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "isDisabled", "type", "testId", "xcss"];
5
+ import React, { forwardRef } from 'react';
6
+ import { xcss } from '../xcss/xcss';
7
+ import Box from './box';
8
+ var defaultStyles = xcss({
10
9
  cursor: 'pointer'
11
10
  });
12
11
 
12
+ // TODO: Duplicated FocusRing styles due to lack of `xcss` support
13
+ // and to prevent additional dependency
14
+ var baseFocusRingStyles = {
15
+ outlineColor: 'color.border.focused',
16
+ outlineWidth: 'border.width.outline',
17
+ outlineStyle: 'solid',
18
+ outlineOffset: 'space.025'
19
+ };
20
+ var focusRingStyles = xcss({
21
+ ':focus-visible': baseFocusRingStyles,
22
+ '@supports not selector(*:focus-visible)': {
23
+ ':focus': baseFocusRingStyles
24
+ },
25
+ '@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
26
+ ':focus-visible': {
27
+ outline: '1px solid'
28
+ }
29
+ }
30
+ });
31
+
13
32
  /**
14
33
  * __UNSAFE_PRESSABLE__
15
34
  *
@@ -35,8 +54,12 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(function (_ref, ref) {
35
54
  _ref$type = _ref.type,
36
55
  type = _ref$type === void 0 ? 'button' : _ref$type,
37
56
  testId = _ref.testId,
57
+ xcssStyles = _ref.xcss,
38
58
  htmlAttributes = _objectWithoutProperties(_ref, _excluded);
39
- return jsx(FocusRing, null, jsx(BaseBox, _extends({}, htmlAttributes, {
59
+ // Combine default styles with supplied styles. XCSS does not support deep nested arrays
60
+ var styles = [defaultStyles, focusRingStyles];
61
+ styles = Array.isArray(xcssStyles) ? [].concat(_toConsumableArray(styles), _toConsumableArray(xcssStyles)) : [].concat(_toConsumableArray(styles), [xcssStyles]);
62
+ return /*#__PURE__*/React.createElement(Box, _extends({}, htmlAttributes, {
40
63
  ref: ref,
41
64
  testId: testId,
42
65
  type: type,
@@ -48,9 +71,11 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(function (_ref, ref) {
48
71
  paddingInline: paddingInline,
49
72
  paddingInlineStart: paddingInlineStart,
50
73
  paddingInlineEnd: paddingInlineEnd,
51
- as: "button",
52
- css: defaultStyles,
74
+ as: "button"
75
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
76
+ ,
77
+ xcss: styles,
53
78
  disabled: isDisabled
54
- }), children));
79
+ }), children);
55
80
  });
56
81
  export default UNSAFE_PRESSABLE;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.11",
3
+ "version": "1.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,6 @@
1
- /** @jsx jsx */
2
1
  import { type ReactElement, type ReactNode } from 'react';
3
- import { type BaseBoxProps } from './internal/base-box';
4
- export type PressableProps = Omit<BaseBoxProps<'button'>, 'disabled' | 'as' | 'children' | 'role' | 'style'> & {
2
+ import { type BoxProps } from './box';
3
+ export type PressableProps = Omit<BoxProps<'button'>, 'disabled' | 'as' | 'children' | 'role' | 'style'> & {
5
4
  /**
6
5
  * `children` should be defined to ensure buttons are not empty,
7
6
  * because they should have labels.
@@ -1,7 +1,6 @@
1
- /** @jsx jsx */
2
1
  import { type ReactElement, type ReactNode } from 'react';
3
- import { type BaseBoxProps } from './internal/base-box';
4
- export type PressableProps = Omit<BaseBoxProps<'button'>, 'disabled' | 'as' | 'children' | 'role' | 'style'> & {
2
+ import { type BoxProps } from './box';
3
+ export type PressableProps = Omit<BoxProps<'button'>, 'disabled' | 'as' | 'children' | 'role' | 'style'> & {
5
4
  /**
6
5
  * `children` should be defined to ensure buttons are not empty,
7
6
  * because they should have labels.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.11",
3
+ "version": "1.1.0",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -113,7 +113,6 @@
113
113
  "codegen-styles": "ts-node -r tsconfig-paths/register ./scripts/codegen-styles.tsx"
114
114
  },
115
115
  "dependencies": {
116
- "@atlaskit/focus-ring": "^1.3.0",
117
116
  "@atlaskit/tokens": "^1.14.0",
118
117
  "@babel/runtime": "^7.0.0",
119
118
  "@emotion/react": "^11.7.1",