@atlaskit/flag 14.5.1 → 14.5.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 (47) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/__perf__/withFlagGroup.tsx +1 -1
  3. package/dist/cjs/auto-dismiss-flag.js +4 -4
  4. package/dist/cjs/flag-actions.js +50 -6
  5. package/dist/cjs/flag-group.js +56 -18
  6. package/dist/cjs/flag.js +83 -106
  7. package/dist/cjs/internal/description.js +32 -0
  8. package/dist/cjs/internal/dismiss-button.js +83 -0
  9. package/dist/cjs/{expander.js → internal/expander.js} +15 -7
  10. package/dist/cjs/internal/index.js +39 -0
  11. package/dist/cjs/internal/title.js +32 -0
  12. package/dist/cjs/theme.js +61 -61
  13. package/dist/cjs/version.json +1 -1
  14. package/dist/es2019/auto-dismiss-flag.js +2 -3
  15. package/dist/es2019/flag-actions.js +50 -32
  16. package/dist/es2019/flag-group.js +48 -65
  17. package/dist/es2019/flag.js +77 -164
  18. package/dist/es2019/internal/description.js +22 -0
  19. package/dist/es2019/internal/dismiss-button.js +63 -0
  20. package/dist/es2019/{expander.js → internal/expander.js} +14 -10
  21. package/dist/es2019/internal/index.js +4 -0
  22. package/dist/es2019/internal/title.js +22 -0
  23. package/dist/es2019/theme.js +61 -61
  24. package/dist/es2019/version.json +1 -1
  25. package/dist/esm/auto-dismiss-flag.js +2 -3
  26. package/dist/esm/flag-actions.js +49 -6
  27. package/dist/esm/flag-group.js +52 -16
  28. package/dist/esm/flag.js +79 -101
  29. package/dist/esm/internal/description.js +23 -0
  30. package/dist/esm/internal/dismiss-button.js +63 -0
  31. package/dist/esm/{expander.js → internal/expander.js} +14 -5
  32. package/dist/esm/internal/index.js +4 -0
  33. package/dist/esm/internal/title.js +23 -0
  34. package/dist/esm/theme.js +61 -61
  35. package/dist/esm/version.json +1 -1
  36. package/dist/types/flag-actions.d.ts +4 -4
  37. package/dist/types/flag-group.d.ts +2 -2
  38. package/dist/types/flag.d.ts +1 -1
  39. package/dist/types/internal/description.d.ts +7 -0
  40. package/dist/types/internal/dismiss-button.d.ts +11 -0
  41. package/dist/types/internal/expander.d.ts +8 -0
  42. package/dist/types/internal/index.d.ts +4 -0
  43. package/dist/types/internal/title.d.ts +6 -0
  44. package/dist/types/theme.d.ts +1 -1
  45. package/package.json +7 -3
  46. package/dist/types/expander.d.ts +0 -9
  47. package/expander/package.json +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/flag
2
2
 
3
+ ## 14.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`19d72473dfb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/19d72473dfb) - Internal changes to support adoption of '@compiled/react'.
8
+ - [`19d72473dfb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/19d72473dfb) - The no-unsafe-design-token-usage eslint rule now respects the new token naming conventions when auto-fixing by correctly formatting token ids.
9
+ - [`19d72473dfb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/19d72473dfb) - The no-unsafe-design-token-usage eslint rule now respects the new token naming conventions when auto-fixing by correctly formatting token ids.
10
+ - [`19d72473dfb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/19d72473dfb) - An a11y fix for the flag dismiss/toggle button such that it retains focus when toggled.
11
+ - Updated dependencies
12
+
3
13
  ## 14.5.1
4
14
 
5
15
  ### Patch Changes
@@ -13,7 +13,7 @@ export default () => (
13
13
  icon={
14
14
  <SuccessIcon
15
15
  label="Success"
16
- secondaryColor={token('color.iconBorder.success', G400)}
16
+ secondaryColor={token('color.icon.success', G400)}
17
17
  />
18
18
  }
19
19
  id="success"
@@ -15,6 +15,8 @@ var _react = _interopRequireWildcard(require("react"));
15
15
 
16
16
  var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatformLeafEventHandler");
17
17
 
18
+ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
19
+
18
20
  var _flag = _interopRequireDefault(require("./flag"));
19
21
 
20
22
  var _flagGroup = require("./flag-group");
@@ -24,17 +26,15 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
24
26
  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; }
25
27
 
26
28
  var packageName = "@atlaskit/flag";
27
- var packageVersion = "14.5.1";
29
+ var packageVersion = "14.5.2";
28
30
  var AUTO_DISMISS_SECONDS = 8;
29
31
  exports.AUTO_DISMISS_SECONDS = AUTO_DISMISS_SECONDS;
30
32
 
31
- function noop() {}
32
-
33
33
  var AutoDismissFlag = function AutoDismissFlag(props) {
34
34
  var id = props.id,
35
35
  analyticsContext = props.analyticsContext,
36
36
  _props$onDismissed = props.onDismissed,
37
- onDismissedProp = _props$onDismissed === void 0 ? noop : _props$onDismissed;
37
+ onDismissedProp = _props$onDismissed === void 0 ? _noop.default : _props$onDismissed;
38
38
  var autoDismissTimer = (0, _react.useRef)(null);
39
39
 
40
40
  var _useFlagGroup = (0, _flagGroup.useFlagGroup)(),
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
-
12
10
  var _core = require("@emotion/core");
13
11
 
14
12
  var _customThemeButton = _interopRequireDefault(require("@atlaskit/button/custom-theme-button"));
@@ -19,11 +17,52 @@ var _constants2 = require("./constants");
19
17
 
20
18
  var _theme = require("./theme");
21
19
 
22
- var _templateObject, _templateObject2, _templateObject3;
20
+ /* eslint-disable @repo/internal/styles/no-nested-styles */
23
21
 
22
+ /** @jsx jsx */
24
23
  var gridSize = (0, _constants.gridSize)();
25
24
  var separatorWidth = gridSize * 2;
26
25
  var defaultAppearanceTranslate = gridSize / 4;
26
+ var separatorStyles = (0, _core.css)({
27
+ display: 'inline-block',
28
+ width: separatorWidth,
29
+ textAlign: 'center'
30
+ });
31
+ var actionContainerStyles = (0, _core.css)({
32
+ display: 'flex',
33
+ paddingTop: gridSize,
34
+ alignItems: 'center',
35
+ flexWrap: 'wrap',
36
+ transform: "translateX(-".concat(defaultAppearanceTranslate, "px)")
37
+ });
38
+ var boldActionContainerStyles = (0, _core.css)({
39
+ transform: 0
40
+ });
41
+ var buttonStyles = (0, _core.css)({
42
+ '&&, a&&': {
43
+ marginLeft: 0,
44
+ padding: "0 ".concat(gridSize, "px !important"),
45
+ background: "var(--bg-color)",
46
+ color: "var(--color) !important",
47
+ fontWeight: 500
48
+ },
49
+ '&&:focus, a&&:focus': {
50
+ boxShadow: "0 0 0 2px var(--focus-color)"
51
+ },
52
+ '&&:hover, &&:active, a&&:hover, a&&:active': {
53
+ textDecoration: 'underline'
54
+ }
55
+ });
56
+ var appeanceNormalButtonStyles = (0, _core.css)({
57
+ '&&, a&&': {
58
+ padding: '0 !important'
59
+ }
60
+ });
61
+ var isBoldButtonStyles = (0, _core.css)({
62
+ '&&, a&&': {
63
+ marginLeft: gridSize
64
+ }
65
+ });
27
66
 
28
67
  var FlagActions = function FlagActions(props) {
29
68
  var _props$appearance = props.appearance,
@@ -40,11 +79,11 @@ var FlagActions = function FlagActions(props) {
40
79
 
41
80
  var isBold = appearance !== _constants2.DEFAULT_APPEARANCE;
42
81
  return (0, _core.jsx)("div", {
43
- css: (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-wrap: wrap;\n padding-top: ", "px;\n transform: ", ";\n align-items: center;\n "])), gridSize, appearance === _constants2.DEFAULT_APPEARANCE ? "translateX(-".concat(defaultAppearanceTranslate, "px)") : 0),
82
+ css: [actionContainerStyles, isBold && boldActionContainerStyles],
44
83
  "data-testid": testId && "".concat(testId, "-actions")
45
84
  }, actions.map(function (action, index) {
46
85
  return [index && !isBold ? (0, _core.jsx)("div", {
47
- css: (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n text-align: center;\n display: inline-block;\n width: ", "px;\n "])), separatorWidth),
86
+ css: separatorStyles,
48
87
  key: index + 0.5
49
88
  }, "\xB7") : '', (0, _core.jsx)(_customThemeButton.default, {
50
89
  onClick: action.onClick,
@@ -55,7 +94,12 @@ var FlagActions = function FlagActions(props) {
55
94
  spacing: "compact",
56
95
  testId: action.testId,
57
96
  key: index,
58
- css: (0, _core.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n &&,\n a&& {\n margin-left: ", "px;\n font-weight: 500;\n padding: 0 ", "px !important;\n background: ", ";\n color: ", " !important;\n }\n &&:focus,\n a&&:focus {\n box-shadow: 0 0 0 2px ", ";\n }\n &&:hover,\n &&:active,\n a&&:hover,\n a&&:active {\n text-decoration: underline;\n }\n "])), index && isBold ? gridSize : 0, appearance === 'normal' ? 0 : gridSize, (0, _theme.getActionBackground)(appearance, mode), (0, _theme.getActionColor)(appearance, mode), (0, _theme.getFlagFocusRingColor)(appearance, mode))
97
+ style: {
98
+ '--color': (0, _theme.getActionColor)(appearance, mode),
99
+ '--bg-color': (0, _theme.getActionBackground)(appearance, mode),
100
+ '--focus-color': (0, _theme.getFlagFocusRingColor)(appearance, mode)
101
+ },
102
+ css: [buttonStyles, isBold && isBoldButtonStyles, appearance === 'normal' && appeanceNormalButtonStyles]
59
103
  }, action.content)];
60
104
  }));
61
105
  };
@@ -10,8 +10,6 @@ exports.useFlagGroup = useFlagGroup;
10
10
 
11
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
12
 
13
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
14
-
15
13
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
16
14
 
17
15
  var _react = require("react");
@@ -20,12 +18,15 @@ var _core = require("@emotion/core");
20
18
 
21
19
  var _motion = require("@atlaskit/motion");
22
20
 
21
+ var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
22
+
23
+ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
24
+
23
25
  var _portal = _interopRequireDefault(require("@atlaskit/portal"));
24
26
 
25
27
  var _constants = require("@atlaskit/theme/constants");
26
28
 
27
- var _templateObject, _templateObject2, _templateObject3;
28
-
29
+ /** @jsx jsx */
29
30
  var gridSize = (0, _constants.gridSize)();
30
31
  var flagWidth = gridSize * 50;
31
32
  exports.flagWidth = flagWidth;
@@ -33,9 +34,6 @@ var flagAnimationTime = 400;
33
34
  exports.flagAnimationTime = flagAnimationTime;
34
35
  var flagBottom = gridSize * 6;
35
36
  var flagLeft = gridSize * 10;
36
-
37
- function noop() {}
38
-
39
37
  var defaultFlagGroupContext = {
40
38
  onDismissed: function onDismissed() {},
41
39
  isDismissAllowed: false
@@ -49,7 +47,51 @@ function useFlagGroup() {
49
47
  // that causes a broken transition
50
48
 
51
49
 
52
- var baseStyles = "\n bottom: 0;\n position: absolute;\n width: ".concat(flagWidth, "px;\n transition: transform ").concat(flagAnimationTime, "ms ease-in-out;\n\n @media (max-width: 560px) {\n width: 100vw;\n }\n\n &:first-of-type {\n transition: none;\n transform: translate(0,0);\n }\n\n &:nth-of-type(n + 2) {\n animation-duration: 0ms;\n transform: translateX(0) translateY(100%) translateY(").concat(2 * gridSize, "px);\n }\n\n /* Layer the 'primary' flag above the 'secondary' flag */\n &:nth-of-type(1) {\n z-index: 5;\n }\n &:nth-of-type(2) {\n z-index: 4;\n }\n\n &:nth-of-type(n + 4) {\n visibility: hidden;\n }\n");
50
+ var baseStyles = (0, _core.css)({
51
+ width: flagWidth,
52
+ position: 'absolute',
53
+ bottom: 0,
54
+ transition: "transform ".concat(flagAnimationTime, "ms ease-in-out"),
55
+ '@media (max-width: 560px)': {
56
+ width: '100vw'
57
+ },
58
+ ':first-of-type': {
59
+ transform: "translate(0,0)",
60
+ transition: 'none'
61
+ },
62
+ ':nth-of-type(n + 2)': {
63
+ animationDuration: '0ms',
64
+ transform: "translateX(0) translateY(100%) translateY(".concat(2 * gridSize, "px)")
65
+ },
66
+ ':nth-of-type(1)': {
67
+ zIndex: 5
68
+ },
69
+ ':nth-of-type(2)': {
70
+ zIndex: 4
71
+ },
72
+ '&:nth-of-type(n + 4)': {
73
+ visibility: 'hidden'
74
+ }
75
+ }); // Transform needed to push up while 1st flag is leaving
76
+ // Exiting time should match the exiting time of motion so is halved
77
+
78
+ var dismissAllowedStyles = (0, _core.css)({
79
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
80
+ '&& + *': {
81
+ transform: "translate(0, 0)",
82
+ transitionDuration: "".concat(flagAnimationTime / 2, "ms")
83
+ }
84
+ });
85
+ var flagGroupContainerStyles = (0, _core.css)({
86
+ position: 'fixed',
87
+ zIndex: _constants.layers.flag(),
88
+ bottom: flagBottom,
89
+ left: flagLeft,
90
+ '@media (max-width: 560px)': {
91
+ bottom: 0,
92
+ left: 0
93
+ }
94
+ });
53
95
 
54
96
  var FlagGroup = function FlagGroup(props) {
55
97
  var id = props.id,
@@ -59,7 +101,7 @@ var FlagGroup = function FlagGroup(props) {
59
101
  LabelTag = _props$labelTag === void 0 ? 'h2' : _props$labelTag,
60
102
  children = props.children,
61
103
  _props$onDismissed = props.onDismissed,
62
- onDismissed = _props$onDismissed === void 0 ? noop : _props$onDismissed;
104
+ onDismissed = _props$onDismissed === void 0 ? _noop.default : _props$onDismissed;
63
105
  var hasFlags = Array.isArray(children) ? children.length > 0 : Boolean(children);
64
106
  var dismissFlagContext = (0, _react.useMemo)(function () {
65
107
  return {
@@ -72,17 +114,15 @@ var FlagGroup = function FlagGroup(props) {
72
114
  return children && (0, _typeof2.default)(children) === 'object' ? _react.Children.map(children, function (flag, index) {
73
115
  var isDismissAllowed = index === 0;
74
116
  return (0, _core.jsx)(_motion.SlideIn, {
75
- enterFrom: 'left',
76
- fade: 'inout',
117
+ enterFrom: "left",
118
+ fade: "inout",
77
119
  duration: flagAnimationTime,
78
120
  animationTimingFunction: function animationTimingFunction() {
79
121
  return _motion.easeIn;
80
122
  }
81
123
  }, function (props) {
82
124
  return (0, _core.jsx)("div", (0, _extends2.default)({}, props, {
83
- css: (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n "])), baseStyles, isDismissAllowed ? // Transform needed to push up while 1st flag is leaving
84
- // Exiting time should match the exiting time of motion so is halved
85
- "\n && + * {\n transform: translate(0, 0);\n transition-duration: ".concat(flagAnimationTime / 2, "ms\n }") : '')
125
+ css: [baseStyles, isDismissAllowed && dismissAllowedStyles]
86
126
  }), (0, _core.jsx)(FlagGroupContext.Provider, {
87
127
  value: // Only the first flag should be able to be dismissed.
88
128
  isDismissAllowed ? dismissFlagContext : defaultFlagGroupContext
@@ -95,10 +135,8 @@ var FlagGroup = function FlagGroup(props) {
95
135
  zIndex: _constants.layers.flag()
96
136
  }, (0, _core.jsx)("div", {
97
137
  id: id,
98
- css: (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n bottom: ", "px;\n left: ", "px;\n position: fixed;\n z-index: ", ";\n @media (max-width: 560px) {\n bottom: 0;\n left: 0;\n }\n "])), flagBottom, flagLeft, _constants.layers.flag())
99
- }, hasFlags ? (0, _core.jsx)(LabelTag, {
100
- css: (0, _core.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n "])))
101
- }, label) : null, (0, _core.jsx)(_motion.ExitingPersistence, {
138
+ css: flagGroupContainerStyles
139
+ }, hasFlags ? (0, _core.jsx)(_visuallyHidden.default, null, (0, _core.jsx)(LabelTag, null, label)) : null, (0, _core.jsx)(_motion.ExitingPersistence, {
102
140
  appear: false
103
141
  }, renderChildren())));
104
142
  };
package/dist/cjs/flag.js CHANGED
@@ -9,8 +9,6 @@ exports.default = void 0;
9
9
 
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
 
12
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
-
14
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
13
 
16
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
@@ -19,44 +17,55 @@ var _react = require("react");
19
17
 
20
18
  var _core = require("@emotion/core");
21
19
 
22
- var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
23
-
24
- var _chevronUp = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-up"));
25
-
26
- var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
27
-
28
- var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
20
+ var _components = require("@atlaskit/theme/components");
29
21
 
30
22
  var _constants = require("@atlaskit/theme/constants");
31
23
 
32
24
  var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatformLeafEventHandler");
33
25
 
26
+ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
27
+
28
+ var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
29
+
34
30
  var _constants2 = require("./constants");
35
31
 
36
32
  var _theme = require("./theme");
37
33
 
38
- var _expander = _interopRequireDefault(require("./expander"));
39
-
40
34
  var _flagActions = _interopRequireDefault(require("./flag-actions"));
41
35
 
42
36
  var _flagGroup = require("./flag-group");
43
37
 
44
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
38
+ var _internal = require("./internal");
45
39
 
46
40
  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; }
47
41
 
48
42
  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; }
49
43
 
50
- function noop() {}
51
-
52
44
  var analyticsAttributes = {
53
45
  componentName: 'flag',
54
46
  packageName: "@atlaskit/flag",
55
- packageVersion: "14.5.1"
47
+ packageVersion: "14.5.2"
56
48
  };
57
49
  var gridSize = (0, _constants.gridSize)();
58
50
  var doubleGridSize = gridSize * 2;
59
51
  var headerHeight = gridSize * 4;
52
+ var iconStyles = (0, _core.css)({
53
+ display: 'flex',
54
+ height: headerHeight,
55
+ alignItems: 'center'
56
+ });
57
+ var flagHeaderStyles = (0, _core.css)({
58
+ boxSizing: 'border-box',
59
+ width: '100%',
60
+ padding: doubleGridSize,
61
+ borderRadius: (0, _constants.borderRadius)()
62
+ });
63
+ var flagContainerStyles = (0, _core.css)({
64
+ width: '100%',
65
+ zIndex: _constants.layers.flag(),
66
+ borderRadius: (0, _constants.borderRadius)(),
67
+ transition: 'background-color 200ms'
68
+ });
60
69
 
61
70
  var Flag = function Flag(props) {
62
71
  var _props$actions = props.actions,
@@ -69,12 +78,12 @@ var Flag = function Flag(props) {
69
78
  linkComponent = props.linkComponent,
70
79
  onMouseOver = props.onMouseOver,
71
80
  _props$onFocus = props.onFocus,
72
- onFocus = _props$onFocus === void 0 ? noop : _props$onFocus,
81
+ onFocus = _props$onFocus === void 0 ? _noop.default : _props$onFocus,
73
82
  onMouseOut = props.onMouseOut,
74
83
  _props$onBlur = props.onBlur,
75
- onBlur = _props$onBlur === void 0 ? noop : _props$onBlur,
84
+ onBlur = _props$onBlur === void 0 ? _noop.default : _props$onBlur,
76
85
  _props$onDismissed = props.onDismissed,
77
- onDismissedProp = _props$onDismissed === void 0 ? noop : _props$onDismissed,
86
+ onDismissedProp = _props$onDismissed === void 0 ? _noop.default : _props$onDismissed,
78
87
  testId = props.testId,
79
88
  id = props.id,
80
89
  analyticsContext = props.analyticsContext;
@@ -99,60 +108,16 @@ var Flag = function Flag(props) {
99
108
  analyticsData: analyticsContext
100
109
  }, analyticsAttributes));
101
110
  var isBold = appearance !== _constants2.DEFAULT_APPEARANCE;
102
- var renderToggleOrDismissButton = (0, _react.useCallback)(function (_ref) {
103
- var mode = _ref.mode;
104
-
105
- // If it is normal appearance a toggle button cannot be rendered
106
- // Ensure onDismissed is defined and isDismissAllowed is true to render
107
- // the dismiss button
108
- if (!isBold && !isDismissAllowed) {
109
- return null;
110
- } // If it is bold then ensure there is a description or actions to render
111
- // the toggle button
112
-
113
-
114
- if (isBold && !description && !actions.length) {
115
- return null;
111
+ var toggleExpand = (0, _react.useCallback)(function () {
112
+ setIsExpanded(function (previous) {
113
+ return !previous;
114
+ });
115
+ }, []);
116
+ var buttonActionCallback = (0, _react.useCallback)(function () {
117
+ if (isDismissAllowed) {
118
+ onDismissedAnalytics(id);
116
119
  }
117
-
118
- var ButtonIcon = _cross.default;
119
- var buttonLabel = 'Dismiss';
120
-
121
- var buttonAction = function buttonAction() {
122
- if (isDismissAllowed) {
123
- onDismissedAnalytics(id);
124
- }
125
- };
126
-
127
- var size = 'small';
128
- var buttonTestId = testId && "".concat(testId, "-dismiss");
129
- var a11yProps = {};
130
-
131
- if (isBold) {
132
- ButtonIcon = isExpanded ? _chevronUp.default : _chevronDown.default;
133
- buttonLabel = isExpanded ? 'Collapse' : 'Expand';
134
-
135
- buttonAction = function buttonAction() {
136
- return setIsExpanded(!isExpanded);
137
- };
138
-
139
- size = 'large';
140
- buttonTestId = testId && "".concat(testId, "-toggle");
141
- a11yProps = {
142
- 'aria-expanded': isExpanded
143
- };
144
- }
145
-
146
- return (0, _core.jsx)("button", (0, _extends2.default)({
147
- css: (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n appearance: none;\n background: none;\n border: none;\n border-radius: ", "px;\n color: ", ";\n cursor: pointer;\n flex: 0 0 auto;\n line-height: 1;\n margin-left: ", "px;\n padding: 0;\n white-space: nowrap;\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n "])), (0, _constants.borderRadius)(), (0, _theme.getFlagTextColor)(appearance, mode), gridSize, (0, _theme.getFlagFocusRingColor)(appearance, mode)),
148
- onClick: buttonAction,
149
- "data-testid": buttonTestId,
150
- type: "button"
151
- }, a11yProps), (0, _core.jsx)(ButtonIcon, {
152
- label: buttonLabel,
153
- size: size
154
- }));
155
- }, [actions.length, appearance, description, id, isBold, isDismissAllowed, isExpanded, onDismissedAnalytics, testId]);
120
+ }, [onDismissedAnalytics, id, isDismissAllowed]);
156
121
  (0, _react.useEffect)(function () {
157
122
  // If buttons are removed as a prop, update isExpanded to be false
158
123
  if (isBold && isExpanded && !description && !actions.length) {
@@ -175,45 +140,57 @@ var Flag = function Flag(props) {
175
140
  onMouseOut: onMouseOut,
176
141
  onBlur: onBlurAnalytics
177
142
  };
178
- var OptionalDismissButton = renderToggleOrDismissButton;
179
- var boxShadow = "var(--ds-overlay, ".concat("0 20px 32px -8px ".concat(_theme.flagShadowColor), ")");
143
+ var boxShadow = "var(--ds-shadow-overlay, ".concat("0 20px 32px -8px ".concat(_theme.flagShadowColor), ")");
180
144
 
181
145
  if (!isBold) {
182
- boxShadow = "var(--ds-overlay, ".concat("0 0 1px ".concat(_theme.flagBorderColor, ", ").concat(boxShadow), ")");
146
+ boxShadow = "var(--ds-shadow-overlay, ".concat("0 0 1px ".concat(_theme.flagBorderColor, ", ").concat(boxShadow), ")");
183
147
  }
184
148
 
185
- return (0, _core.jsx)(_components.default.Consumer, null, function (tokens) {
186
- var mode = tokens.mode;
187
- var textColour = (0, _theme.getFlagTextColor)(appearance, mode);
188
- var iconColour = (0, _theme.getFlagIconColor)(appearance, mode);
189
- return (0, _core.jsx)("div", (0, _extends2.default)({
190
- css: (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n background-color: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n color: ", ";\n transition: background-color 200ms;\n width: 100%;\n z-index: ", ";\n "])), (0, _theme.getFlagBackgroundColor)(appearance, mode), (0, _constants.borderRadius)(), boxShadow, textColour, _constants.layers.flag()),
191
- role: "alert",
192
- "data-testid": testId
193
- }, autoDismissProps), (0, _core.jsx)("div", {
194
- css: (0, _core.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n padding: ", "px;\n box-sizing: border-box;\n border-radius: ", "px;\n\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px\n ", ";\n }\n\n @supports not selector(*:focus-visible) {\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px\n ", ";\n }\n }\n\n @media screen and (forced-colors: active),\n screen and (-ms-high-contrast: active) {\n &:focus-visible {\n outline: 1px solid;\n }\n }\n "])), doubleGridSize, (0, _constants.borderRadius)(), (0, _theme.getFlagFocusRingColor)(appearance, mode), (0, _theme.getFlagFocusRingColor)(appearance, mode)) // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
195
- ,
196
- tabIndex: 0
197
- }, (0, _core.jsx)("div", {
198
- css: (0, _core.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n display: flex;\n align-items: center;\n height: ", "px;\n "])), iconColour, headerHeight)
199
- }, icon, (0, _core.jsx)("span", {
200
- css: (0, _core.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-weight: 600;\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n padding: 0 0 0 ", "px;\n "])), textColour, doubleGridSize)
201
- }, title), (0, _core.jsx)(OptionalDismissButton, {
202
- mode: mode
203
- })), (0, _core.jsx)(_expander.default, {
204
- isExpanded: !isBold || isExpanded,
205
- testId: testId
206
- }, description && (0, _core.jsx)("div", {
207
- css: (0, _core.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n word-wrap: break-word;\n overflow: auto;\n max-height: 100px; /* height is defined as 5 lines maximum by design */\n "])), textColour),
208
- "data-testid": testId && "".concat(testId, "-description")
209
- }, description), (0, _core.jsx)(_flagActions.default, {
210
- actions: actions,
211
- appearance: appearance,
212
- linkComponent: linkComponent,
213
- testId: testId,
214
- mode: mode
215
- }))));
216
- });
149
+ var _useGlobalTheme = (0, _components.useGlobalTheme)(),
150
+ mode = _useGlobalTheme.mode;
151
+
152
+ var textColor = (0, _theme.getFlagTextColor)(appearance, mode);
153
+ var iconColor = (0, _theme.getFlagIconColor)(appearance, mode);
154
+ var isDismissable = isBold || isDismissAllowed;
155
+ return (0, _core.jsx)("div", (0, _extends2.default)({
156
+ style: {
157
+ color: textColor,
158
+ backgroundColor: (0, _theme.getFlagBackgroundColor)(appearance, mode),
159
+ boxShadow: boxShadow
160
+ },
161
+ css: flagContainerStyles,
162
+ role: "alert",
163
+ "data-testid": testId
164
+ }, autoDismissProps), (0, _core.jsx)(_focusRing.default, null, (0, _core.jsx)("div", {
165
+ css: flagHeaderStyles // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
166
+ ,
167
+ tabIndex: 0
168
+ }, (0, _core.jsx)("div", {
169
+ style: {
170
+ color: iconColor
171
+ },
172
+ css: iconStyles
173
+ }, icon, (0, _core.jsx)(_internal.Title, {
174
+ color: textColor
175
+ }, title), isDismissable ? !(isBold && !description && !actions.length) && (0, _core.jsx)(_internal.DismissButton, {
176
+ testId: testId,
177
+ appearance: appearance,
178
+ isBold: isBold,
179
+ isExpanded: isExpanded,
180
+ onClick: isBold ? toggleExpand : buttonActionCallback
181
+ }) : null), (0, _core.jsx)(_internal.Expander, {
182
+ isExpanded: !isBold || isExpanded,
183
+ testId: testId
184
+ }, description && (0, _core.jsx)(_internal.Description, {
185
+ testId: testId && "".concat(testId, "-description"),
186
+ color: textColor
187
+ }, description), (0, _core.jsx)(_flagActions.default, {
188
+ actions: actions,
189
+ appearance: appearance,
190
+ linkComponent: linkComponent,
191
+ testId: testId,
192
+ mode: mode
193
+ })))));
217
194
  };
218
195
 
219
196
  var _default = Flag;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _core = require("@emotion/core");
9
+
10
+ /** @jsx jsx */
11
+ var descriptionStyles = (0, _core.css)({
12
+ /* height is defined as 5 lines maximum by design */
13
+ maxHeight: 100,
14
+ overflow: 'auto',
15
+ wordWrap: 'break-word'
16
+ });
17
+
18
+ var Description = function Description(_ref) {
19
+ var color = _ref.color,
20
+ testId = _ref.testId,
21
+ children = _ref.children;
22
+ return (0, _core.jsx)("div", {
23
+ style: {
24
+ color: color
25
+ },
26
+ css: descriptionStyles,
27
+ "data-testid": testId
28
+ }, children);
29
+ };
30
+
31
+ var _default = Description;
32
+ exports.default = _default;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _react = require("react");
11
+
12
+ var _core = require("@emotion/core");
13
+
14
+ var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
15
+
16
+ var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
17
+
18
+ var _chevronUp = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-up"));
19
+
20
+ var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
21
+
22
+ var _constants = require("@atlaskit/theme/constants");
23
+
24
+ var _components = require("@atlaskit/theme/components");
25
+
26
+ var _theme = require("../theme");
27
+
28
+ /** @jsx jsx */
29
+ var gridSize = (0, _constants.gridSize)();
30
+ var borderRadius = (0, _constants.borderRadius)();
31
+ var dismissButtonStyles = (0, _core.css)({
32
+ marginLeft: gridSize,
33
+ padding: 0,
34
+ flex: '0 0 auto',
35
+ appearance: 'none',
36
+ background: 'none',
37
+ border: 'none',
38
+ borderRadius: borderRadius,
39
+ cursor: 'pointer',
40
+ lineHeight: '1',
41
+ whiteSpace: 'nowrap'
42
+ });
43
+
44
+ var DismissButton = function DismissButton(_ref) {
45
+ var appearance = _ref.appearance,
46
+ onClick = _ref.onClick,
47
+ isBold = _ref.isBold,
48
+ isExpanded = _ref.isExpanded,
49
+ testId = _ref.testId;
50
+
51
+ var _useGlobalTheme = (0, _components.useGlobalTheme)(),
52
+ mode = _useGlobalTheme.mode;
53
+
54
+ var ButtonIcon = _cross.default;
55
+ var buttonLabel = 'Dismiss';
56
+ var size = 'small';
57
+ var buttonTestId = testId && "".concat(testId, "-dismiss");
58
+
59
+ if (isBold) {
60
+ ButtonIcon = isExpanded ? _chevronUp.default : _chevronDown.default;
61
+ buttonLabel = isExpanded ? 'Collapse' : 'Expand';
62
+ size = 'large';
63
+ buttonTestId = testId && "".concat(testId, "-toggle");
64
+ }
65
+
66
+ return (0, _core.jsx)(_focusRing.default, null, (0, _core.jsx)("button", {
67
+ style: {
68
+ color: (0, _theme.getFlagTextColor)(appearance, mode)
69
+ },
70
+ css: dismissButtonStyles,
71
+ onClick: onClick,
72
+ "data-testid": buttonTestId,
73
+ type: "button",
74
+ "aria-expanded": isBold ? isExpanded : undefined
75
+ }, (0, _core.jsx)(ButtonIcon, {
76
+ label: buttonLabel,
77
+ size: size
78
+ })));
79
+ };
80
+
81
+ var _default = /*#__PURE__*/(0, _react.memo)(DismissButton);
82
+
83
+ exports.default = _default;