@atlaskit/status 5.10.1 → 5.11.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.
@@ -4,11 +4,27 @@ import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useEffect, useRef, useCallback } from 'react';
5
5
  import { fg } from '@atlaskit/platform-feature-flags/fg';
6
6
  import { useThemeObserver } from '@atlaskit/tokens/use-theme-observer';
7
+ import { isSwatchSelected, COLORS, PICKER_SWATCHES, SWATCH_ICON_COLOR } from '../status-colors';
7
8
  import Color from './color';
8
9
  const paletteLegacy = [['neutral', "var(--ds-background-neutral, #0515240F)", "var(--ds-border-bold, #7D818A)", "var(--ds-icon, #292A2E)"], ['purple', "var(--ds-background-discovery, #F8EEFE)", "var(--ds-border-discovery, #AF59E1)", "var(--ds-icon-discovery, #AF59E1)"], ['blue', "var(--ds-background-information, #E9F2FE)", "var(--ds-border-information, #357DE8)", "var(--ds-icon-information, #357DE8)"], ['red', "var(--ds-background-danger, #FFECEB)", "var(--ds-border-danger, #E2483D)", "var(--ds-icon-danger, #C9372C)"], ['yellow', "var(--ds-background-warning, #FFF5DB)", "var(--ds-border-warning, #E06C00)", "var(--ds-icon-warning, #E06C00)"], ['green', "var(--ds-background-success, #EFFFD6)", "var(--ds-border-success, #6A9A23)", "var(--ds-icon-success, #6A9A23)"]];
9
10
  const paletteRefreshed = [['neutral', "var(--ds-background-accent-gray-subtler, #DDDEE1)", "var(--ds-border-bold, #7D818A)", "var(--ds-icon, #292A2E)"], ['blue', "var(--ds-background-information-pressed, #ADCBFB)", "var(--ds-border-information, #357DE8)", "var(--ds-icon, #292A2E)"], ['green', "var(--ds-background-success-pressed, #BDE97C)", "var(--ds-border-success, #6A9A23)", "var(--ds-icon, #292A2E)"], ['yellow', "var(--ds-background-warning-pressed, #FBD779)", "var(--ds-border-warning, #E06C00)", "var(--ds-icon, #292A2E)"], ['red', "var(--ds-background-danger-pressed, #FFB8B2)", "var(--ds-border-danger, #E2483D)", "var(--ds-icon, #292A2E)"], ['purple', "var(--ds-background-discovery-pressed, #E3BDFA)", "var(--ds-border-discovery, #AF59E1)", "var(--ds-icon, #292A2E)"]];
10
11
  const paletteTeam26 = [['neutral', "var(--ds-background-neutral, #0515240F)", '#CACBCF', '#63666B', "var(--ds-icon, #292A2E)"], ['blue', "var(--ds-background-information-subtler, #CFE1FD)", '#8FB8F6', '#1558BC', "var(--ds-icon, #292A2E)"], ['green', "var(--ds-background-success-subtler, #D3F1A7)", '#B3DF72', '#4C6B1F', "var(--ds-icon, #292A2E)"], ['yellow', "var(--ds-background-warning-subtler, #FCE4A6)", '#FBC828', '#9E4C00', "var(--ds-icon, #292A2E)"], ['red', "var(--ds-background-danger-subtler, #FFD5D2)", '#FD9891', '#AE2E24', "var(--ds-icon, #292A2E)"], ['purple', "var(--ds-background-discovery-subtler, #EED7FC)", '#D8A0F7', '#803FA5', "var(--ds-icon, #292A2E)"]];
11
- const getPalette = colorMode => {
12
+ // Derived from the status colour registry so the swatch list, the Lozenge appearances
13
+ // and the i18n keys cannot drift apart. See COLORS.
14
+ const paletteHex = PICKER_SWATCHES.flatMap(value => {
15
+ const swatch = COLORS[value].swatch;
16
+ return swatch ? [[value, swatch.backgroundColor, swatch.borderColor, SWATCH_ICON_COLOR]] : [];
17
+ });
18
+
19
+ /** Columns each variant is laid out in; `extended` wraps its ten swatches onto two rows. */
20
+ const variantToCols = {
21
+ default: 7,
22
+ extended: 5
23
+ };
24
+ const getPalette = (colorMode, variant = 'default') => {
25
+ if (variant === 'extended') {
26
+ return paletteHex;
27
+ }
12
28
  if (fg('platform-dst-lozenge-tag-badge-visual-uplifts')) {
13
29
  const isDark = colorMode === 'dark';
14
30
  return paletteTeam26.map(([colorValue, backgroundColor, lightBorderColor, darkBorderColor, iconColor]) => [colorValue, backgroundColor, isDark ? darkBorderColor : lightBorderColor, iconColor]);
@@ -19,16 +35,18 @@ const getPalette = colorMode => {
19
35
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/design-system/no-css-tagged-template-expression -- Ignored via go/DSP-18766
20
36
  const colorPaletteWrapperStyles = null;
21
37
  export default (({
22
- cols = 7,
38
+ cols,
23
39
  onClick,
24
40
  selectedColor,
25
41
  className,
26
- onHover
42
+ onHover,
43
+ palette: variant = 'default'
27
44
  }) => {
28
45
  const {
29
46
  colorMode
30
47
  } = useThemeObserver();
31
- const palette = getPalette(colorMode);
48
+ const palette = getPalette(colorMode, variant);
49
+ const resolvedCols = cols !== null && cols !== void 0 ? cols : variantToCols[variant];
32
50
  const colorRefs = useRef([]);
33
51
  useEffect(() => {
34
52
  colorRefs.current = colorRefs.current.slice(0, palette.length);
@@ -59,7 +77,7 @@ export default (({
59
77
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
60
78
  className: ax(["_19bvidpf _19pku2gc _2hwxu2gc _otyridpf _18u0u2gc _1e0c1txw _1n261g80", className]),
61
79
  style: {
62
- maxWidth: cols * 32
80
+ maxWidth: resolvedCols * 32
63
81
  }
64
82
  }, palette.map(([colorValue, backgroundColor, borderColor, iconColor], i) => /*#__PURE__*/React.createElement(Color, {
65
83
  key: colorValue,
@@ -69,7 +87,7 @@ export default (({
69
87
  iconColor: iconColor,
70
88
  onClick: onClick,
71
89
  onHover: onHover,
72
- isSelected: colorValue === selectedColor,
90
+ isSelected: isSwatchSelected(colorValue, selectedColor),
73
91
  tabIndex: i === 0 ? 0 : -1,
74
92
  setRef: el => colorRefs.current[i] = el,
75
93
  onKeyDown: createKeyDownHandler(i)
@@ -9,6 +9,7 @@ import { PureComponent } from 'react';
9
9
  import { FormattedMessage } from 'react-intl';
10
10
  import { ANALYTICS_HOVER_DELAY } from '../constants';
11
11
  import { messages } from '../i18n';
12
+ import { getColorLabelKey } from '../status-colors';
12
13
  const styles = {
13
14
  button: "_2rko12b0 _19itia51 _1reo15vq _18m915vq _4t3i1tcg _1bsb1tcg _bfhki8nm _ca0qze3t _u5f3ze3t _n3tdze3t _19bvze3t _1e0c1ule"
14
15
  };
@@ -55,7 +56,7 @@ export default class Color extends PureComponent {
55
56
  } = this.props;
56
57
  return /*#__PURE__*/React.createElement("li", {
57
58
  className: ax(["_2rko12x7 _189ee4h9 _1dqonqa1 _1h6d1j28 _19pkze3t _2hwxv77o _otyrze3t _18u0v77o _1e0c1txw _4cvr1h6o _ca0qe4h9 _u5f3e4h9 _n3tde4h9 _19bve4h9 _bfw7ia51"])
58
- }, /*#__PURE__*/React.createElement(FormattedMessage, messages[`${value}Color`], labels => /*#__PURE__*/React.createElement(Pressable, {
59
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages[getColorLabelKey(value)], labels => /*#__PURE__*/React.createElement(Pressable, {
59
60
  xcss: styles.button,
60
61
  onClick: this.onClick,
61
62
  onMouseEnter: this.onMouseEnter,
@@ -0,0 +1,217 @@
1
+ import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
2
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
3
+
4
+ /** Named colours the ADF `color` attribute can carry. */
5
+
6
+ export const NAMED_COLORS = ['neutral', 'purple', 'blue', 'red', 'yellow', 'green'];
7
+
8
+ /**
9
+ * Hex ids the picker persists — the hues with no existing named ADF colour.
10
+ * Each is the panel-medium hex for that accent, so it resolves to the same token
11
+ * the editor palette would give it.
12
+ */
13
+
14
+ export const HEX_PALETTE = ['#B3F5FF',
15
+ // Teal
16
+ '#ABF5D1',
17
+ // Green
18
+ '#D3F1A7',
19
+ // Lime — named `green` renders identically
20
+ '#FFF0B3',
21
+ // Yellow
22
+ '#FCE4A6',
23
+ // Orange — named `yellow` renders identically
24
+ '#FDD0EC' // Magenta
25
+ ];
26
+ export const DEFAULT_LOZENGE_APPEARANCE = 'neutral';
27
+
28
+ /** Pre-experiment mapping. Delete with `platform_editor_update_status_colors`. */
29
+ export const colorToLozengeAppearanceMap = {
30
+ neutral: 'neutral',
31
+ purple: 'discovery',
32
+ blue: 'information',
33
+ red: 'danger',
34
+ yellow: 'warning',
35
+ green: 'success'
36
+ };
37
+
38
+ /**
39
+ * Check-mark colour for the selected swatch. Uniform across the ten-colour palette, so
40
+ * it is not a per-colour field. (The legacy six-colour palette does vary it, which is
41
+ * why `ColorProps` still takes it per swatch.)
42
+ */
43
+ export const SWATCH_ICON_COLOR = "var(--ds-icon, #292A2E)";
44
+
45
+ /**
46
+ * Keys of `messages` usable as a swatch's accessible name. Kept as a union so
47
+ * `getColorLabelKey` returns something `messages` is guaranteed to have — the
48
+ * call site in `color.tsx` then needs no cast, and an unregistered colour cannot
49
+ * produce a missing key.
50
+ */
51
+
52
+ /**
53
+ * Single source of truth for status colours: appearance, swatch tokens and i18n key.
54
+ * Typed as a total `Record`, so adding a value to NAMED_COLORS or HEX_PALETTE
55
+ * fails to compile until it is described here.
56
+ *
57
+ * Legacy named `yellow`/`green` have no swatch — they are not offered separately,
58
+ * because `accent-orange`/`accent-lime` are byte-identical to the Orange/Lime swatches
59
+ * in both themes. The distinct Yellow and Green swatches are the #FFF0B3 / #ABF5D1 hues.
60
+ *
61
+ * CSS cannot be derived from this: Compiled needs static literals and the styling lint
62
+ * rule rejects computed values. `statusStylesHexAccent` in editor-core mirrors it by hand.
63
+ */
64
+ export const COLORS = {
65
+ neutral: {
66
+ appearance: 'neutral',
67
+ labelKey: 'neutralColor',
68
+ swatch: {
69
+ backgroundColor: "var(--ds-background-neutral, #0515240F)",
70
+ borderColor: "var(--ds-border, #0B120E24)"
71
+ }
72
+ },
73
+ blue: {
74
+ appearance: 'accent-blue',
75
+ labelKey: 'blueColor',
76
+ swatch: {
77
+ backgroundColor: "var(--ds-background-accent-blue-subtler, #CFE1FD)",
78
+ borderColor: "var(--ds-border-accent-blue-subtle, #8FB8F6)"
79
+ }
80
+ },
81
+ '#B3F5FF': {
82
+ appearance: 'accent-teal',
83
+ labelKey: 'tealColor',
84
+ swatch: {
85
+ backgroundColor: "var(--ds-background-accent-teal-subtler, #C6EDFB)",
86
+ borderColor: "var(--ds-border-accent-teal-subtle, #9DD9EE)"
87
+ }
88
+ },
89
+ '#ABF5D1': {
90
+ appearance: 'accent-green',
91
+ labelKey: 'greenColor',
92
+ swatch: {
93
+ backgroundColor: "var(--ds-background-accent-green-subtler, #BAF3DB)",
94
+ borderColor: "var(--ds-border-accent-green-subtle, #7EE2B8)"
95
+ }
96
+ },
97
+ '#D3F1A7': {
98
+ appearance: 'accent-lime',
99
+ labelKey: 'limeColor',
100
+ swatch: {
101
+ backgroundColor: "var(--ds-background-accent-lime-subtler, #D3F1A7)",
102
+ borderColor: "var(--ds-border-accent-lime-subtle, #B3DF72)"
103
+ }
104
+ },
105
+ '#FFF0B3': {
106
+ appearance: 'accent-yellow',
107
+ labelKey: 'yellowColor',
108
+ swatch: {
109
+ backgroundColor: "var(--ds-background-accent-yellow-subtler, #F5E989)",
110
+ borderColor: "var(--ds-border-accent-yellow-subtle, #EED12B)"
111
+ }
112
+ },
113
+ '#FCE4A6': {
114
+ appearance: 'accent-orange',
115
+ labelKey: 'orangeColor',
116
+ swatch: {
117
+ backgroundColor: "var(--ds-background-accent-orange-subtler, #FCE4A6)",
118
+ borderColor: "var(--ds-border-accent-orange-subtle, #FBC828)"
119
+ }
120
+ },
121
+ red: {
122
+ appearance: 'accent-red',
123
+ labelKey: 'redColor',
124
+ swatch: {
125
+ backgroundColor: "var(--ds-background-accent-red-subtler, #FFD5D2)",
126
+ borderColor: "var(--ds-border-accent-red-subtle, #FD9891)"
127
+ }
128
+ },
129
+ '#FDD0EC': {
130
+ appearance: 'accent-magenta',
131
+ labelKey: 'magentaColor',
132
+ swatch: {
133
+ backgroundColor: "var(--ds-background-accent-magenta-subtler, #FDD0EC)",
134
+ borderColor: "var(--ds-border-accent-magenta-subtle, #F797D2)"
135
+ }
136
+ },
137
+ purple: {
138
+ appearance: 'accent-purple',
139
+ labelKey: 'purpleColor',
140
+ swatch: {
141
+ backgroundColor: "var(--ds-background-accent-purple-subtler, #EED7FC)",
142
+ borderColor: "var(--ds-border-accent-purple-subtle, #D8A0F7)"
143
+ }
144
+ },
145
+ yellow: {
146
+ appearance: 'accent-orange',
147
+ labelKey: 'yellowColor'
148
+ },
149
+ green: {
150
+ appearance: 'accent-lime',
151
+ labelKey: 'greenColor'
152
+ }
153
+ };
154
+
155
+ /** Swatch order in the ten-colour picker: two rows of five. */
156
+ export const PICKER_SWATCHES = ['neutral',
157
+ // Gray
158
+ 'blue',
159
+ // Blue
160
+ '#B3F5FF',
161
+ // Teal
162
+ '#ABF5D1',
163
+ // Green
164
+ '#D3F1A7',
165
+ // Lime
166
+ '#FFF0B3',
167
+ // Yellow
168
+ '#FCE4A6',
169
+ // Orange
170
+ 'red',
171
+ // Red
172
+ '#FDD0EC',
173
+ // Magenta
174
+ 'purple' // Purple
175
+ ];
176
+ export const isNamedColor = color => NAMED_COLORS.includes(color);
177
+ export const normalizeColor = color => color.startsWith('#') ? color.toUpperCase() : color;
178
+ const specFor = color => COLORS[normalizeColor(color)];
179
+
180
+ /**
181
+ * Falls back to the neutral label rather than building a key from the colour: an
182
+ * unregistered value would otherwise yield a key `messages` does not have, and
183
+ * spreading the resulting `undefined` into `FormattedMessage` throws.
184
+ */
185
+ export const getColorLabelKey = color => {
186
+ var _specFor$labelKey, _specFor;
187
+ return (_specFor$labelKey = (_specFor = specFor(color)) === null || _specFor === void 0 ? void 0 : _specFor.labelKey) !== null && _specFor$labelKey !== void 0 ? _specFor$labelKey : 'neutralColor';
188
+ };
189
+ export const isSwatchSelected = (swatchValue, selectedColor) => {
190
+ var _specFor2, _specFor3;
191
+ if (!selectedColor) {
192
+ return false;
193
+ }
194
+ if (normalizeColor(swatchValue) === normalizeColor(selectedColor)) {
195
+ return true;
196
+ }
197
+
198
+ // A swatch also counts as selected when it renders the same hue under a different
199
+ // id — legacy named `green`/`yellow` share the Lime/Orange swatches. Unknown values
200
+ // have no spec, so they never collide on the neutral fallback.
201
+ const swatchAppearance = (_specFor2 = specFor(swatchValue)) === null || _specFor2 === void 0 ? void 0 : _specFor2.appearance;
202
+ return swatchAppearance !== undefined && swatchAppearance === ((_specFor3 = specFor(selectedColor)) === null || _specFor3 === void 0 ? void 0 : _specFor3.appearance);
203
+ };
204
+ export const getLozengeAppearance = color => {
205
+ const isUpdateStatusColorsEnabled = UNSAFE_expValNoExposure('platform_editor_update_status_colors', 'isEnabled', false);
206
+
207
+ // Named colours are recoloured only by the experiment. `gracefully_render_status_color`
208
+ // is a read-path gate for hex written by another cohort, so it must never reach here.
209
+ if (isNamedColor(color)) {
210
+ return isUpdateStatusColorsEnabled ? COLORS[color].appearance : colorToLozengeAppearanceMap[color];
211
+ }
212
+ if (isUpdateStatusColorsEnabled || fg('platform_editor_gracefully_render_status_color')) {
213
+ var _specFor$appearance, _specFor4;
214
+ return (_specFor$appearance = (_specFor4 = specFor(color)) === null || _specFor4 === void 0 ? void 0 : _specFor4.appearance) !== null && _specFor$appearance !== void 0 ? _specFor$appearance : DEFAULT_LOZENGE_APPEARANCE;
215
+ }
216
+ return DEFAULT_LOZENGE_APPEARANCE;
217
+ };
@@ -15,15 +15,13 @@ import Lozenge from '@atlaskit/lozenge/lozenge';
15
15
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
16
16
  import { createStatusAnalyticsAndFire } from './analytics';
17
17
  import { ANALYTICS_HOVER_DELAY } from './constants';
18
- var colorToLozengeAppearanceMap = {
19
- neutral: 'neutral',
20
- purple: 'discovery',
21
- blue: 'information',
22
- red: 'danger',
23
- yellow: 'warning',
24
- green: 'success'
25
- };
26
- var DEFAULT_APPEARANCE = 'neutral';
18
+ import { getLozengeAppearance, normalizeColor } from './status-colors';
19
+
20
+ /**
21
+ * What the ADF `color` attribute can hold. `HexColor` is the closed set we persist — do
22
+ * not substitute it here, or graceful rendering of unknown hex becomes a type error.
23
+ */
24
+
27
25
  var MAX_WIDTH = 200;
28
26
 
29
27
  /**
@@ -99,7 +97,7 @@ var StatusInternal = /*#__PURE__*/function (_PureComponent) {
99
97
  if (text.trim().length === 0) {
100
98
  return null;
101
99
  }
102
- var appearance = colorToLozengeAppearanceMap[color] || DEFAULT_APPEARANCE;
100
+ var appearance = getLozengeAppearance(color);
103
101
  // Note: ommitted data-local-id attribute to avoid copying/pasting the same localId
104
102
  return /*#__PURE__*/React.createElement("span", {
105
103
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -112,7 +110,7 @@ var StatusInternal = /*#__PURE__*/function (_PureComponent) {
112
110
  onBlur: this.handleBlur,
113
111
  tabIndex: onClick ? -1 : undefined,
114
112
  "data-node-type": "status",
115
- "data-color": color,
113
+ "data-color": normalizeColor(color),
116
114
  "data-style": style,
117
115
  role: role
118
116
  }, /*#__PURE__*/React.createElement(Lozenge, {
@@ -14,6 +14,13 @@ import React, { PureComponent } from 'react';
14
14
  import { injectIntl } from 'react-intl';
15
15
  import ColorPalette from './internal/color-palette';
16
16
  import { messages } from './i18n';
17
+
18
+ /**
19
+ * Which set of selectable values the picker offers.
20
+ * - `default`: the six named colours.
21
+ * - `extended`: ten colours; hues without an existing name are persisted as hex.
22
+ */
23
+
17
24
  var fieldTextWrapperStyles = null;
18
25
 
19
26
  // Keep the existing content position while reserving space inside the scrollport for focus rings.
@@ -65,12 +72,14 @@ var Picker = /*#__PURE__*/function (_PureComponent) {
65
72
  onColorClick = _this$props.onColorClick,
66
73
  onColorHover = _this$props.onColorHover,
67
74
  intl = _this$props.intl,
68
- scrollableContent = _this$props.scrollableContent;
75
+ scrollableContent = _this$props.scrollableContent,
76
+ palette = _this$props.palette;
69
77
  var colorPalette = /*#__PURE__*/React.createElement(ColorPalette, {
70
78
  key: this.colorPaletteKey,
71
79
  onClick: onColorClick,
72
80
  onHover: onColorHover,
73
- selectedColor: selectedColor
81
+ selectedColor: selectedColor,
82
+ palette: palette
74
83
  });
75
84
 
76
85
  // Using <React.Fragment> instead of [] to workaround Enzyme
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  export var ELEMENTS_CHANNEL = 'fabric-elements';
5
5
  var packageName = "@atlaskit/status";
6
- var packageVersion = "5.10.0";
6
+ var packageVersion = "5.10.1";
7
7
  export var createStatusAnalyticsAndFire = function createStatusAnalyticsAndFire(createAnalyticsEvent) {
8
8
  return function (payload) {
9
9
  var statusPayload = _objectSpread(_objectSpread({}, payload), {}, {
@@ -2,8 +2,8 @@ import { defineMessages } from 'react-intl';
2
2
  export var messages = defineMessages({
3
3
  neutralColor: {
4
4
  id: 'fabric.status.color.grey',
5
- defaultMessage: 'Grey',
6
- description: 'Tooltip for the grey color in color palette'
5
+ defaultMessage: 'Gray',
6
+ description: 'Tooltip for the gray color in color palette'
7
7
  },
8
8
  purpleColor: {
9
9
  id: 'fabric.status.color.purple',
@@ -30,6 +30,26 @@ export var messages = defineMessages({
30
30
  defaultMessage: 'Green',
31
31
  description: 'Tooltip for the green color in color palette'
32
32
  },
33
+ tealColor: {
34
+ id: 'fabric.status.color.teal',
35
+ defaultMessage: 'Teal',
36
+ description: 'Tooltip for the teal color in color palette'
37
+ },
38
+ limeColor: {
39
+ id: 'fabric.status.color.lime',
40
+ defaultMessage: 'Lime',
41
+ description: 'Tooltip for the lime color in color palette'
42
+ },
43
+ orangeColor: {
44
+ id: 'fabric.status.color.orange',
45
+ defaultMessage: 'Orange',
46
+ description: 'Tooltip for the orange color in color palette'
47
+ },
48
+ magentaColor: {
49
+ id: 'fabric.status.color.magenta',
50
+ defaultMessage: 'Magenta',
51
+ description: 'Tooltip for the magenta color in color palette'
52
+ },
33
53
  statusInputLabel: {
34
54
  id: 'fabric.status.input.label',
35
55
  defaultMessage: 'Set a status',
@@ -5,11 +5,28 @@ import { ax, ix } from "@compiled/react/runtime";
5
5
  import React, { useEffect, useRef, useCallback } from 'react';
6
6
  import { fg } from '@atlaskit/platform-feature-flags/fg';
7
7
  import { useThemeObserver } from '@atlaskit/tokens/use-theme-observer';
8
+ import { isSwatchSelected, COLORS, PICKER_SWATCHES, SWATCH_ICON_COLOR } from '../status-colors';
8
9
  import Color from './color';
9
10
  var paletteLegacy = [['neutral', "var(--ds-background-neutral, #0515240F)", "var(--ds-border-bold, #7D818A)", "var(--ds-icon, #292A2E)"], ['purple', "var(--ds-background-discovery, #F8EEFE)", "var(--ds-border-discovery, #AF59E1)", "var(--ds-icon-discovery, #AF59E1)"], ['blue', "var(--ds-background-information, #E9F2FE)", "var(--ds-border-information, #357DE8)", "var(--ds-icon-information, #357DE8)"], ['red', "var(--ds-background-danger, #FFECEB)", "var(--ds-border-danger, #E2483D)", "var(--ds-icon-danger, #C9372C)"], ['yellow', "var(--ds-background-warning, #FFF5DB)", "var(--ds-border-warning, #E06C00)", "var(--ds-icon-warning, #E06C00)"], ['green', "var(--ds-background-success, #EFFFD6)", "var(--ds-border-success, #6A9A23)", "var(--ds-icon-success, #6A9A23)"]];
10
11
  var paletteRefreshed = [['neutral', "var(--ds-background-accent-gray-subtler, #DDDEE1)", "var(--ds-border-bold, #7D818A)", "var(--ds-icon, #292A2E)"], ['blue', "var(--ds-background-information-pressed, #ADCBFB)", "var(--ds-border-information, #357DE8)", "var(--ds-icon, #292A2E)"], ['green', "var(--ds-background-success-pressed, #BDE97C)", "var(--ds-border-success, #6A9A23)", "var(--ds-icon, #292A2E)"], ['yellow', "var(--ds-background-warning-pressed, #FBD779)", "var(--ds-border-warning, #E06C00)", "var(--ds-icon, #292A2E)"], ['red', "var(--ds-background-danger-pressed, #FFB8B2)", "var(--ds-border-danger, #E2483D)", "var(--ds-icon, #292A2E)"], ['purple', "var(--ds-background-discovery-pressed, #E3BDFA)", "var(--ds-border-discovery, #AF59E1)", "var(--ds-icon, #292A2E)"]];
11
12
  var paletteTeam26 = [['neutral', "var(--ds-background-neutral, #0515240F)", '#CACBCF', '#63666B', "var(--ds-icon, #292A2E)"], ['blue', "var(--ds-background-information-subtler, #CFE1FD)", '#8FB8F6', '#1558BC', "var(--ds-icon, #292A2E)"], ['green', "var(--ds-background-success-subtler, #D3F1A7)", '#B3DF72', '#4C6B1F', "var(--ds-icon, #292A2E)"], ['yellow', "var(--ds-background-warning-subtler, #FCE4A6)", '#FBC828', '#9E4C00', "var(--ds-icon, #292A2E)"], ['red', "var(--ds-background-danger-subtler, #FFD5D2)", '#FD9891', '#AE2E24', "var(--ds-icon, #292A2E)"], ['purple', "var(--ds-background-discovery-subtler, #EED7FC)", '#D8A0F7', '#803FA5', "var(--ds-icon, #292A2E)"]];
13
+ // Derived from the status colour registry so the swatch list, the Lozenge appearances
14
+ // and the i18n keys cannot drift apart. See COLORS.
15
+ var paletteHex = PICKER_SWATCHES.flatMap(function (value) {
16
+ var swatch = COLORS[value].swatch;
17
+ return swatch ? [[value, swatch.backgroundColor, swatch.borderColor, SWATCH_ICON_COLOR]] : [];
18
+ });
19
+
20
+ /** Columns each variant is laid out in; `extended` wraps its ten swatches onto two rows. */
21
+ var variantToCols = {
22
+ default: 7,
23
+ extended: 5
24
+ };
12
25
  var getPalette = function getPalette(colorMode) {
26
+ var variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
27
+ if (variant === 'extended') {
28
+ return paletteHex;
29
+ }
13
30
  if (fg('platform-dst-lozenge-tag-badge-visual-uplifts')) {
14
31
  var isDark = colorMode === 'dark';
15
32
  return paletteTeam26.map(function (_ref) {
@@ -28,15 +45,17 @@ var getPalette = function getPalette(colorMode) {
28
45
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/design-system/no-css-tagged-template-expression -- Ignored via go/DSP-18766
29
46
  var colorPaletteWrapperStyles = null;
30
47
  export default (function (_ref3) {
31
- var _ref3$cols = _ref3.cols,
32
- cols = _ref3$cols === void 0 ? 7 : _ref3$cols,
48
+ var cols = _ref3.cols,
33
49
  onClick = _ref3.onClick,
34
50
  selectedColor = _ref3.selectedColor,
35
51
  className = _ref3.className,
36
- onHover = _ref3.onHover;
52
+ onHover = _ref3.onHover,
53
+ _ref3$palette = _ref3.palette,
54
+ variant = _ref3$palette === void 0 ? 'default' : _ref3$palette;
37
55
  var _useThemeObserver = useThemeObserver(),
38
56
  colorMode = _useThemeObserver.colorMode;
39
- var palette = getPalette(colorMode);
57
+ var palette = getPalette(colorMode, variant);
58
+ var resolvedCols = cols !== null && cols !== void 0 ? cols : variantToCols[variant];
40
59
  var colorRefs = useRef([]);
41
60
  useEffect(function () {
42
61
  colorRefs.current = colorRefs.current.slice(0, palette.length);
@@ -73,7 +92,7 @@ export default (function (_ref3) {
73
92
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
74
93
  className: ax(["_19bvidpf _19pku2gc _2hwxu2gc _otyridpf _18u0u2gc _1e0c1txw _1n261g80", className]),
75
94
  style: {
76
- maxWidth: cols * 32
95
+ maxWidth: resolvedCols * 32
77
96
  }
78
97
  }, palette.map(function (_ref4, i) {
79
98
  var _ref5 = _slicedToArray(_ref4, 4),
@@ -89,7 +108,7 @@ export default (function (_ref3) {
89
108
  iconColor: iconColor,
90
109
  onClick: onClick,
91
110
  onHover: onHover,
92
- isSelected: colorValue === selectedColor,
111
+ isSelected: isSwatchSelected(colorValue, selectedColor),
93
112
  tabIndex: i === 0 ? 0 : -1,
94
113
  setRef: function setRef(el) {
95
114
  return colorRefs.current[i] = el;
@@ -16,6 +16,7 @@ import { PureComponent } from 'react';
16
16
  import { FormattedMessage } from 'react-intl';
17
17
  import { ANALYTICS_HOVER_DELAY } from '../constants';
18
18
  import { messages } from '../i18n';
19
+ import { getColorLabelKey } from '../status-colors';
19
20
  var styles = {
20
21
  button: "_2rko12b0 _19itia51 _1reo15vq _18m915vq _4t3i1tcg _1bsb1tcg _bfhki8nm _ca0qze3t _u5f3ze3t _n3tdze3t _19bvze3t _1e0c1ule"
21
22
  };
@@ -68,7 +69,7 @@ var Color = /*#__PURE__*/function (_PureComponent) {
68
69
  onKeyDown = _this$props2.onKeyDown;
69
70
  return /*#__PURE__*/React.createElement("li", {
70
71
  className: ax(["_2rko12x7 _189ee4h9 _1dqonqa1 _1h6d1j28 _19pkze3t _2hwxv77o _otyrze3t _18u0v77o _1e0c1txw _4cvr1h6o _ca0qe4h9 _u5f3e4h9 _n3tde4h9 _19bve4h9 _bfw7ia51"])
71
- }, /*#__PURE__*/React.createElement(FormattedMessage, messages["".concat(value, "Color")], function (labels) {
72
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages[getColorLabelKey(value)], function (labels) {
72
73
  return /*#__PURE__*/React.createElement(Pressable, {
73
74
  xcss: styles.button,
74
75
  onClick: _this2.onClick,