@atlaskit/flag 14.7.2 → 15.0.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/auto-dismiss-flag.js +1 -1
  3. package/dist/cjs/flag-actions.js +18 -37
  4. package/dist/cjs/flag-group.js +15 -9
  5. package/dist/cjs/flag.js +62 -69
  6. package/dist/cjs/internal/dismiss-button.js +25 -38
  7. package/dist/cjs/internal/expander.js +25 -26
  8. package/dist/cjs/internal/index.js +0 -16
  9. package/dist/cjs/theme.js +50 -169
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/auto-dismiss-flag.js +1 -1
  12. package/dist/es2019/flag-actions.js +18 -38
  13. package/dist/es2019/flag-group.js +14 -8
  14. package/dist/es2019/flag.js +62 -67
  15. package/dist/es2019/internal/dismiss-button.js +26 -36
  16. package/dist/es2019/internal/expander.js +20 -23
  17. package/dist/es2019/internal/index.js +0 -2
  18. package/dist/es2019/theme.js +47 -141
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/auto-dismiss-flag.js +1 -1
  21. package/dist/esm/flag-actions.js +18 -38
  22. package/dist/esm/flag-group.js +14 -8
  23. package/dist/esm/flag.js +62 -68
  24. package/dist/esm/internal/dismiss-button.js +26 -37
  25. package/dist/esm/internal/expander.js +21 -24
  26. package/dist/esm/internal/index.js +0 -2
  27. package/dist/esm/theme.js +49 -155
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/flag-actions.d.ts +2 -5
  30. package/dist/types/flag.d.ts +3 -2
  31. package/dist/types/internal/expander.d.ts +2 -3
  32. package/dist/types/internal/index.d.ts +0 -2
  33. package/dist/types/theme.d.ts +14 -9
  34. package/package.json +9 -15
  35. package/report.api.md +62 -148
  36. package/dist/cjs/internal/description.js +0 -34
  37. package/dist/cjs/internal/title.js +0 -30
  38. package/dist/es2019/internal/description.js +0 -24
  39. package/dist/es2019/internal/title.js +0 -20
  40. package/dist/esm/internal/description.js +0 -25
  41. package/dist/esm/internal/title.js +0 -21
  42. package/dist/types/internal/description.d.ts +0 -8
  43. package/dist/types/internal/title.d.ts +0 -6
  44. package/dist/types-ts4.0/auto-dismiss-flag.d.ts +0 -13
  45. package/dist/types-ts4.0/constants.d.ts +0 -2
  46. package/dist/types-ts4.0/flag-actions.d.ts +0 -15
  47. package/dist/types-ts4.0/flag-group.d.ts +0 -45
  48. package/dist/types-ts4.0/flag-provider.d.ts +0 -33
  49. package/dist/types-ts4.0/flag.d.ts +0 -14
  50. package/dist/types-ts4.0/index.d.ts +0 -6
  51. package/dist/types-ts4.0/internal/description.d.ts +0 -8
  52. package/dist/types-ts4.0/internal/dismiss-button.d.ts +0 -12
  53. package/dist/types-ts4.0/internal/expander.d.ts +0 -8
  54. package/dist/types-ts4.0/internal/index.d.ts +0 -4
  55. package/dist/types-ts4.0/internal/title.d.ts +0 -6
  56. package/dist/types-ts4.0/theme.d.ts +0 -10
  57. package/dist/types-ts4.0/types.d.ts +0 -101
@@ -1,22 +1,7 @@
1
- /** @jsx jsx */
2
- import { css, jsx } from '@emotion/react';
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { UNSAFE_Box as Box, UNSAFE_Stack as Stack } from '@atlaskit/ds-explorations';
3
4
  import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
4
- import { gridSize as getGridSize } from '@atlaskit/theme/constants';
5
- const gridSize = getGridSize();
6
- const paddingLeft = gridSize * 5;
7
- const expanderStyles = css({
8
- display: 'flex',
9
- minWidth: 0,
10
- maxHeight: 0,
11
- padding: `0 0 0 ${paddingLeft}px`,
12
- justifyContent: 'center',
13
- flex: '1 1 100%',
14
- flexDirection: 'column',
15
- transition: `max-height 0.3s`
16
- });
17
- const expandedStyles = css({
18
- maxHeight: 150
19
- });
20
5
 
21
6
  const Expander = ({
22
7
  children,
@@ -26,13 +11,25 @@ const Expander = ({
26
11
  // Need to always render the ExpanderInternal otherwise the
27
12
  // reveal transition doesn't happen. We can't use CSS animation for
28
13
  // the the reveal because we don't know the height of the content.
29
- return jsx("div", {
14
+ return /*#__PURE__*/React.createElement(Box, {
15
+ UNSAFE_style: {
16
+ minWidth: 0,
17
+ maxHeight: isExpanded ? 150 : 0,
18
+ flex: '1 1 100%',
19
+ transition: `max-height 0.3s`
20
+ },
30
21
  "aria-hidden": !isExpanded,
31
- css: [expanderStyles, isExpanded && expandedStyles],
32
- "data-testid": testId && `${testId}-expander`
33
- }, jsx(ExitingPersistence, {
22
+ testId: testId && `${testId}-expander`
23
+ }, /*#__PURE__*/React.createElement(ExitingPersistence, {
34
24
  appear: true
35
- }, isExpanded && jsx(FadeIn, null, props => jsx("div", props, children))));
25
+ }, isExpanded && /*#__PURE__*/React.createElement(FadeIn, null, props => /*#__PURE__*/React.createElement(Box, _extends({
26
+ display: "block",
27
+ UNSAFE_style: {
28
+ width: '100%'
29
+ }
30
+ }, props), /*#__PURE__*/React.createElement(Stack, {
31
+ gap: "scale.100"
32
+ }, children)))));
36
33
  }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
37
34
 
38
35
 
@@ -1,4 +1,2 @@
1
- export { default as Title } from './title';
2
- export { default as Description } from './description';
3
1
  export { default as Expander } from './expander';
4
2
  export { default as DismissButton } from './dismiss-button';
@@ -1,149 +1,55 @@
1
- import { B100, B400, DN40, DN50, DN600, G300, G400, N0, N200, N30A, N40, N500, N50A, N60A, N700, R300, R400, Y200, Y300 } from '@atlaskit/theme/colors';
2
- const flagBackgroundColor = {
3
- error: {
4
- light: `var(--ds-background-danger-bold, ${R400})`,
5
- dark: `var(--ds-background-danger-bold, ${R300})`
6
- },
7
- info: {
8
- light: `var(--ds-background-neutral-bold, ${N500})`,
9
- dark: `var(--ds-background-neutral-bold, ${N500})`
10
- },
11
- normal: {
12
- light: `var(--ds-surface-overlay, ${N0})`,
13
- dark: `var(--ds-surface-overlay, ${DN50})`
14
- },
15
- success: {
16
- light: `var(--ds-background-success-bold, ${G400})`,
17
- dark: `var(--ds-background-success-bold, ${G300})`
18
- },
19
- warning: {
20
- light: `var(--ds-background-warning-bold, ${Y200})`,
21
- dark: `var(--ds-background-warning-bold, ${Y300})`
22
- }
1
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
+ import { B100, B400, N0, N200, N30A, N40, N500, N700 } from '@atlaskit/theme/colors';
3
+ export const flagBackgroundColor = {
4
+ error: 'danger.bold',
5
+ info: 'neutral.bold',
6
+ normal: 'elevation.surface.overlay',
7
+ success: 'success.bold',
8
+ warning: 'warning.bold'
9
+ };
10
+ export const flagIconColor = {
11
+ error: `var(--ds-icon-inverse, ${N0})`,
12
+ info: `var(--ds-icon-inverse, ${N0})`,
13
+ normal: `var(--ds-icon-subtle, ${N500})`,
14
+ success: `var(--ds-icon-inverse, ${N0})`,
15
+ warning: `var(--ds-icon-warning-inverse, ${N700})`
23
16
  };
24
- export const getFlagBackgroundColor = (appearance, mode) => flagBackgroundColor[appearance][mode]; // token set in flag.tsx instead
25
-
26
17
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
27
18
 
28
- export const flagBorderColor = N60A;
29
- export const flagShadowColor = N50A;
30
- /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
31
-
32
- const flagIconColor = {
33
- error: {
34
- light: `var(--ds-icon-inverse, ${N0})`,
35
- dark: `var(--ds-icon-inverse, ${DN40})`
36
- },
37
- info: {
38
- light: `var(--ds-icon-inverse, ${N0})`,
39
- dark: `var(--ds-icon-inverse, ${DN600})`
40
- },
41
- normal: {
42
- light: `var(--ds-icon-subtle, ${N500})`,
43
- dark: `var(--ds-icon-subtle, ${DN600})`
44
- },
45
- success: {
46
- light: `var(--ds-icon-inverse, ${N0})`,
47
- dark: `var(--ds-icon-inverse, ${DN40})`
48
- },
49
- warning: {
50
- light: `var(--ds-icon-warning-inverse, ${N700})`,
51
- dark: `var(--ds-icon-warning-inverse, ${DN40})`
52
- }
53
- };
54
- const flagTextColor = {
55
- error: {
56
- light: `var(--ds-text-inverse, ${N0})`,
57
- dark: `var(--ds-text-inverse, ${DN40})`
58
- },
59
- info: {
60
- light: `var(--ds-text-inverse, ${N0})`,
61
- dark: `var(--ds-text-inverse, ${DN600})`
62
- },
63
- normal: {
64
- light: `var(--ds-text-subtle, ${N500})`,
65
- dark: `var(--ds-text-subtle, ${DN600})`
66
- },
67
- success: {
68
- light: `var(--ds-text-inverse, ${N0})`,
69
- dark: `var(--ds-text-inverse, ${DN40})`
70
- },
71
- warning: {
72
- light: `var(--ds-text-warning-inverse, ${N700})`,
73
- dark: `var(--ds-text-warning-inverse, ${DN40})`
74
- }
19
+ export const flagTextColor = {
20
+ error: 'inverse',
21
+ info: 'inverse',
22
+ normal: 'subtle',
23
+ success: 'inverse',
24
+ warning: 'warning.inverse'
75
25
  };
76
- export const getFlagTextColor = (appearance, mode) => flagTextColor[appearance][mode];
77
- export const getFlagIconColor = (appearance, mode) => flagIconColor[appearance][mode];
78
- const flagFocusRingColor = {
79
- error: {
80
- light: `var(--ds-border-focused, ${N40})`,
81
- dark: `var(--ds-border-focused, ${N40})`
82
- },
83
- info: {
84
- light: `var(--ds-border-focused, ${N40})`,
85
- dark: `var(--ds-border-focused, ${N40})`
86
- },
87
- normal: {
88
- light: `var(--ds-border-focused, ${B100})`,
89
- dark: `var(--ds-border-focused, ${B100})`
90
- },
91
- success: {
92
- light: `var(--ds-border-focused, ${N40})`,
93
- dark: `var(--ds-border-focused, ${N40})`
94
- },
95
- warning: {
96
- light: `var(--ds-border-focused, ${N200})`,
97
- dark: `var(--ds-border-focused, ${N200})`
98
- }
26
+ export const flagTextColorToken = {
27
+ error: `var(--ds-text-inverse, ${N0})`,
28
+ info: `var(--ds-text-inverse, ${N0})`,
29
+ normal: `var(--ds-text-subtle, ${N500})`,
30
+ success: `var(--ds-text-inverse, ${N0})`,
31
+ warning: `var(--ds-text-warning-inverse, ${N700})`
99
32
  };
100
- export const getFlagFocusRingColor = (appearance, mode) => flagFocusRingColor[appearance][mode];
101
- const lightButtonBackground = 'rgba(255, 255, 255, 0.08)'; // TODO: DSP-2519 Interaction tokens should be used for hovered and pressed states
33
+ export const flagFocusRingColor = {
34
+ error: `var(--ds-border-focused, ${N40})`,
35
+ info: `var(--ds-border-focused, ${N40})`,
36
+ normal: `var(--ds-border-focused, ${B100})`,
37
+ success: `var(--ds-border-focused, ${N40})`,
38
+ warning: `var(--ds-border-focused, ${N200})`
39
+ }; // TODO: DSP-2519 Interaction tokens should be used for hovered and pressed states
102
40
  // https://product-fabric.atlassian.net/browse/DSP-2519
103
41
 
104
- const actionBackground = {
105
- success: {
106
- light: `var(--ds-background-neutral, ${lightButtonBackground})`,
107
- dark: `var(--ds-background-neutral, ${N30A})`
108
- },
109
- info: {
110
- light: `var(--ds-background-neutral, ${lightButtonBackground})`,
111
- dark: `var(--ds-background-neutral, ${lightButtonBackground})`
112
- },
113
- error: {
114
- light: `var(--ds-background-neutral, ${lightButtonBackground})`,
115
- dark: `var(--ds-background-neutral, ${N30A})`
116
- },
117
- warning: {
118
- light: `var(--ds-background-neutral, ${N30A})`,
119
- dark: `var(--ds-background-neutral, ${N30A})`
120
- },
121
- normal: {
122
- light: 'none',
123
- dark: 'none'
124
- }
125
- };
126
- const actionColor = {
127
- success: {
128
- light: `var(--ds-text-inverse, ${N0})`,
129
- dark: `var(--ds-text-inverse, ${DN40})`
130
- },
131
- info: {
132
- light: `var(--ds-text-inverse, ${N0})`,
133
- dark: `var(--ds-text-inverse, ${DN600})`
134
- },
135
- error: {
136
- light: `var(--ds-text-inverse, ${N0})`,
137
- dark: `var(--ds-text-inverse, ${DN600})`
138
- },
139
- warning: {
140
- light: `var(--ds-text-warning-inverse, ${N700})`,
141
- dark: `var(--ds-text-warning-inverse, ${DN40})`
142
- },
143
- normal: {
144
- light: `var(--ds-link, ${B400})`,
145
- dark: `var(--ds-link, ${B100})`
146
- }
42
+ export const actionBackgroundColor = {
43
+ success: `var(--ds-background-neutral, ${N30A})`,
44
+ info: `var(--ds-background-neutral, ${N30A})`,
45
+ error: `var(--ds-background-neutral, ${N30A})`,
46
+ warning: `var(--ds-background-neutral, ${N30A})`,
47
+ normal: 'none'
147
48
  };
148
- export const getActionBackground = (appearance, mode) => actionBackground[appearance][mode];
149
- export const getActionColor = (appearance, mode) => actionColor[appearance][mode];
49
+ export const actionTextColor = {
50
+ success: `var(--ds-text-inverse, ${N0})`,
51
+ info: `var(--ds-text-inverse, ${N0})`,
52
+ error: `var(--ds-text-inverse, ${N0})`,
53
+ warning: `var(--ds-text-warning-inverse, ${N700})`,
54
+ normal: `var(--ds-link, ${B400})`
55
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/flag",
3
- "version": "14.7.2",
3
+ "version": "15.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -5,7 +5,7 @@ import noop from '@atlaskit/ds-lib/noop';
5
5
  import Flag from './flag';
6
6
  import { useFlagGroup } from './flag-group';
7
7
  var packageName = "@atlaskit/flag";
8
- var packageVersion = "14.7.2";
8
+ var packageVersion = "15.0.0";
9
9
  export var AUTO_DISMISS_SECONDS = 8;
10
10
  /**
11
11
  * __Auto dismiss flag__
@@ -3,30 +3,13 @@
3
3
  /** @jsx jsx */
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import Button from '@atlaskit/button/custom-theme-button';
6
+ import { UNSAFE_Inline as Inline } from '@atlaskit/ds-explorations';
6
7
  import { gridSize as getGridSize } from '@atlaskit/theme/constants';
7
8
  import { DEFAULT_APPEARANCE } from './constants';
8
- import { getActionBackground, getActionColor, getFlagFocusRingColor } from './theme';
9
+ import { flagFocusRingColor, actionBackgroundColor, actionTextColor } from './theme';
9
10
  var gridSize = getGridSize();
10
- var separatorWidth = gridSize * 2;
11
- var defaultAppearanceTranslate = gridSize / 4;
12
- var separatorStyles = css({
13
- display: 'inline-block',
14
- width: separatorWidth,
15
- textAlign: 'center'
16
- });
17
- var actionContainerStyles = css({
18
- display: 'flex',
19
- paddingTop: gridSize,
20
- alignItems: 'center',
21
- flexWrap: 'wrap',
22
- transform: "translateX(-".concat(defaultAppearanceTranslate, "px)")
23
- });
24
- var boldActionContainerStyles = css({
25
- transform: 0
26
- });
27
11
  var buttonStyles = css({
28
12
  '&&, a&&': {
29
- marginLeft: 0,
30
13
  padding: "0 ".concat(gridSize, "px !important"),
31
14
  background: "var(--bg-color)",
32
15
  color: "var(--color) !important",
@@ -39,16 +22,11 @@ var buttonStyles = css({
39
22
  textDecoration: 'underline'
40
23
  }
41
24
  });
42
- var appeanceNormalButtonStyles = css({
25
+ var appearanceNormalButtonStyles = css({
43
26
  '&&, a&&': {
44
27
  padding: '0 !important'
45
28
  }
46
29
  });
47
- var isBoldButtonStyles = css({
48
- '&&, a&&': {
49
- marginRight: gridSize
50
- }
51
- });
52
30
 
53
31
  var FlagActions = function FlagActions(props) {
54
32
  var _props$appearance = props.appearance,
@@ -56,7 +34,6 @@ var FlagActions = function FlagActions(props) {
56
34
  _props$actions = props.actions,
57
35
  actions = _props$actions === void 0 ? [] : _props$actions,
58
36
  linkComponent = props.linkComponent,
59
- mode = props.mode,
60
37
  testId = props.testId;
61
38
 
62
39
  if (!actions.length) {
@@ -64,14 +41,17 @@ var FlagActions = function FlagActions(props) {
64
41
  }
65
42
 
66
43
  var isBold = appearance !== DEFAULT_APPEARANCE;
67
- return jsx("div", {
68
- css: [actionContainerStyles, isBold && boldActionContainerStyles],
69
- "data-testid": testId && "".concat(testId, "-actions")
44
+ return jsx(Inline, {
45
+ gap: "scale.100",
46
+ flexWrap: "wrap",
47
+ alignItems: "center",
48
+ divider: isBold ? null : '·',
49
+ UNSAFE_style: isBold ? undefined : {
50
+ transform: "translateX(-2px)"
51
+ },
52
+ testId: testId && "".concat(testId, "-actions")
70
53
  }, actions.map(function (action, index) {
71
- return [index && !isBold ? jsx("div", {
72
- css: separatorStyles,
73
- key: index + 0.5
74
- }, "\xB7") : '', jsx(Button, {
54
+ return jsx(Button, {
75
55
  onClick: action.onClick,
76
56
  href: action.href,
77
57
  target: action.target,
@@ -81,12 +61,12 @@ var FlagActions = function FlagActions(props) {
81
61
  testId: action.testId,
82
62
  key: index,
83
63
  style: {
84
- '--color': getActionColor(appearance, mode),
85
- '--bg-color': getActionBackground(appearance, mode),
86
- '--focus-color': getFlagFocusRingColor(appearance, mode)
64
+ '--color': actionTextColor[appearance],
65
+ '--bg-color': actionBackgroundColor[appearance],
66
+ '--focus-color': flagFocusRingColor[appearance]
87
67
  },
88
- css: [buttonStyles, isBold && isBoldButtonStyles, appearance === 'normal' && appeanceNormalButtonStyles]
89
- }, action.content)];
68
+ css: [buttonStyles, appearance === 'normal' && appearanceNormalButtonStyles]
69
+ }, action.content);
90
70
  }));
91
71
  }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
92
72
 
@@ -1,9 +1,9 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _typeof from "@babel/runtime/helpers/typeof";
3
2
 
4
3
  /** @jsx jsx */
5
4
  import { Children, createContext, useContext, useMemo } from 'react';
6
5
  import { css, jsx } from '@emotion/react';
6
+ import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
7
7
  import { easeIn, ExitingPersistence, SlideIn } from '@atlaskit/motion';
8
8
  import VisuallyHidden from '@atlaskit/visually-hidden';
9
9
  import noop from '@atlaskit/ds-lib/noop';
@@ -28,7 +28,6 @@ export function useFlagGroup() {
28
28
 
29
29
  var baseStyles = css({
30
30
  width: flagWidth,
31
- position: 'absolute',
32
31
  bottom: 0,
33
32
  transition: "transform ".concat(flagAnimationTime, "ms ease-in-out"),
34
33
  '@media (max-width: 560px)': {
@@ -62,7 +61,6 @@ var dismissAllowedStyles = css({
62
61
  }
63
62
  });
64
63
  var flagGroupContainerStyles = css({
65
- position: 'fixed',
66
64
  zIndex: layers.flag(),
67
65
  bottom: flagBottom,
68
66
  left: flagLeft,
@@ -107,10 +105,16 @@ var FlagGroup = function FlagGroup(props) {
107
105
  animationTimingFunction: function animationTimingFunction() {
108
106
  return easeIn;
109
107
  }
110
- }, function (props) {
111
- return jsx("div", _extends({}, props, {
112
- css: [baseStyles, isDismissAllowed && dismissAllowedStyles]
113
- }), jsx(FlagGroupContext.Provider, {
108
+ }, function (_ref) {
109
+ var className = _ref.className,
110
+ ref = _ref.ref;
111
+ return jsx(Box, {
112
+ display: "block",
113
+ position: "absolute",
114
+ css: [baseStyles, isDismissAllowed && dismissAllowedStyles],
115
+ className: className,
116
+ ref: ref
117
+ }, jsx(FlagGroupContext.Provider, {
114
118
  value: // Only the first flag should be able to be dismissed.
115
119
  isDismissAllowed ? dismissFlagContext : defaultFlagGroupContext
116
120
  }, flag));
@@ -120,7 +124,9 @@ var FlagGroup = function FlagGroup(props) {
120
124
 
121
125
  return jsx(Portal, {
122
126
  zIndex: layers.flag()
123
- }, jsx("div", {
127
+ }, jsx(Box, {
128
+ display: "block",
129
+ position: "fixed",
124
130
  id: id,
125
131
  css: flagGroupContainerStyles
126
132
  }, hasFlags ? jsx(VisuallyHidden, null, jsx(LabelTag, null, label)) : null, jsx(ExitingPersistence, {
package/dist/esm/flag.js CHANGED
@@ -8,46 +8,21 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
8
8
 
9
9
  /** @jsx jsx */
10
10
  import { useCallback, useEffect, useState } from 'react';
11
- import { css, jsx } from '@emotion/react';
12
- import { useGlobalTheme } from '@atlaskit/theme/components';
13
- import { borderRadius, gridSize as getGridSize, layers } from '@atlaskit/theme/constants';
11
+ import { jsx } from '@emotion/react';
12
+ import { UNSAFE_Box as Box, UNSAFE_Inline as Inline, UNSAFE_Stack as Stack, UNSAFE_Text as Text } from '@atlaskit/ds-explorations';
14
13
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
15
14
  import noop from '@atlaskit/ds-lib/noop';
16
15
  import FocusRing from '@atlaskit/focus-ring';
17
16
  import { DEFAULT_APPEARANCE } from './constants';
18
- import { flagBorderColor, flagShadowColor, getFlagBackgroundColor, getFlagTextColor, getFlagIconColor } from './theme';
17
+ import { flagTextColor, flagBackgroundColor, flagIconColor } from './theme';
19
18
  import Actions from './flag-actions';
20
19
  import { useFlagGroup } from './flag-group';
21
- import { Title, Description, Expander, DismissButton } from './internal';
20
+ import { Expander, DismissButton } from './internal';
22
21
  var analyticsAttributes = {
23
22
  componentName: 'flag',
24
23
  packageName: "@atlaskit/flag",
25
- packageVersion: "14.7.2"
24
+ packageVersion: "15.0.0"
26
25
  };
27
- var gridSize = getGridSize();
28
- var doubleGridSize = gridSize * 2;
29
- var titleGroupStyles = css({
30
- display: 'flex',
31
- alignItems: 'start'
32
- });
33
- var iconTitleStyles = css({
34
- display: 'flex',
35
- paddingTop: "".concat(gridSize / 2, "px"),
36
- alignItems: 'start',
37
- flex: 1
38
- });
39
- var flagHeaderStyles = css({
40
- boxSizing: 'border-box',
41
- width: '100%',
42
- padding: doubleGridSize,
43
- borderRadius: borderRadius()
44
- });
45
- var flagContainerStyles = css({
46
- width: '100%',
47
- zIndex: layers.flag(),
48
- borderRadius: borderRadius(),
49
- transition: 'background-color 200ms'
50
- });
51
26
  /**
52
27
  * __Flag__
53
28
  *
@@ -132,42 +107,55 @@ var Flag = function Flag(props) {
132
107
  onMouseOut: onMouseOut,
133
108
  onBlur: onBlurAnalytics
134
109
  };
135
- var boxShadowValue = "0 20px 32px -8px ".concat(flagShadowColor);
136
-
137
- if (!isBold) {
138
- boxShadowValue = "0 0 1px ".concat(flagBorderColor, ", ").concat(boxShadowValue);
139
- }
140
-
141
- var boxShadow = "var(--ds-shadow-overlay, ".concat(boxShadowValue, ")");
142
-
143
- var _useGlobalTheme = useGlobalTheme(),
144
- mode = _useGlobalTheme.mode;
145
-
146
- var textColor = getFlagTextColor(appearance, mode);
147
- var iconColor = getFlagIconColor(appearance, mode);
110
+ var textColor = flagTextColor[appearance];
111
+ var iconColor = flagIconColor[appearance];
148
112
  var isDismissable = isBold || isDismissAllowed;
149
- return jsx("div", _extends({
150
- style: {
151
- color: textColor,
152
- backgroundColor: getFlagBackgroundColor(appearance, mode),
153
- boxShadow: boxShadow
113
+ var shouldRenderGap = !isBold && (description || actions.length) || isExpanded;
114
+ return jsx(FocusRing, null, jsx(Box, _extends({
115
+ display: "block",
116
+ backgroundColor: flagBackgroundColor[appearance],
117
+ shadow: "overlay",
118
+ padding: "scale.200",
119
+ borderRadius: "normal",
120
+ overflow: "hidden",
121
+ layer: "flag",
122
+ UNSAFE_style: {
123
+ width: '100%',
124
+ transition: 'background-color 200ms'
154
125
  },
155
- css: flagContainerStyles,
156
126
  role: "alert",
157
- "data-testid": testId
158
- }, autoDismissProps), jsx(FocusRing, null, jsx("div", {
159
- css: flagHeaderStyles // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
127
+ tabIndex: 0,
128
+ testId: testId
129
+ }, autoDismissProps), jsx(Inline, {
130
+ gap: "scale.200"
131
+ }, jsx(Box, {
132
+ alignItems: "start",
133
+ UNSAFE_style: {
134
+ color: iconColor,
135
+ flexShrink: 0
136
+ }
137
+ }, icon), jsx(Stack, {
138
+ gap: shouldRenderGap ? 'scale.100' : 'scale.0' // Gap exists even when not expanded due to Expander internals always being in the DOM
160
139
  ,
161
- tabIndex: 0
162
- }, jsx("div", {
163
- style: {
164
- color: iconColor
165
- },
166
- css: titleGroupStyles
167
- }, jsx("div", {
168
- css: iconTitleStyles
169
- }, icon, jsx(Title, {
170
- color: textColor
140
+ UNSAFE_style: {
141
+ flexGrow: 1,
142
+ transition: "gap 0.3s"
143
+ }
144
+ }, jsx(Inline, {
145
+ gap: "scale.100",
146
+ justifyContent: "spaceBetween"
147
+ }, jsx(Box, {
148
+ display: "block",
149
+ UNSAFE_style: {
150
+ paddingTop: 2
151
+ }
152
+ }, jsx(Text, {
153
+ color: textColor,
154
+ fontWeight: "600",
155
+ UNSAFE_style: {
156
+ overflowWrap: 'anywhere' // For cases where a single word is longer than the container (e.g. filenames)
157
+
158
+ }
171
159
  }, title)), isDismissable ? !(isBold && !description && !actions.length) && jsx(DismissButton, {
172
160
  testId: testId,
173
161
  appearance: appearance,
@@ -177,17 +165,23 @@ var Flag = function Flag(props) {
177
165
  }) : null), jsx(Expander, {
178
166
  isExpanded: !isBold || isExpanded,
179
167
  testId: testId
180
- }, description && jsx(Description, {
181
- testId: testId && "".concat(testId, "-description"),
168
+ }, description && jsx(Text, {
169
+ as: "div",
182
170
  color: textColor,
183
- isBold: isBold
171
+ UNSAFE_style: {
172
+ maxHeight: 100,
173
+ // height is defined as 5 lines maximum by design
174
+ overflow: 'auto',
175
+ overflowWrap: 'anywhere' // For cases where a single word is longer than the container (e.g. filenames)
176
+
177
+ },
178
+ testId: testId && "".concat(testId, "-description")
184
179
  }, description), jsx(Actions, {
185
180
  actions: actions,
186
181
  appearance: appearance,
187
182
  linkComponent: linkComponent,
188
- testId: testId,
189
- mode: mode
190
- })))));
183
+ testId: testId
184
+ }))))));
191
185
  };
192
186
 
193
187
  export default Flag;