@atlaskit/status 5.10.0 → 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.
@@ -0,0 +1,223 @@
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 var 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 var 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 var DEFAULT_LOZENGE_APPEARANCE = 'neutral';
27
+
28
+ /** Pre-experiment mapping. Delete with `platform_editor_update_status_colors`. */
29
+ export var 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 var 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 var 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 var 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 var isNamedColor = function isNamedColor(color) {
177
+ return NAMED_COLORS.includes(color);
178
+ };
179
+ export var normalizeColor = function normalizeColor(color) {
180
+ return color.startsWith('#') ? color.toUpperCase() : color;
181
+ };
182
+ var specFor = function specFor(color) {
183
+ return COLORS[normalizeColor(color)];
184
+ };
185
+
186
+ /**
187
+ * Falls back to the neutral label rather than building a key from the colour: an
188
+ * unregistered value would otherwise yield a key `messages` does not have, and
189
+ * spreading the resulting `undefined` into `FormattedMessage` throws.
190
+ */
191
+ export var getColorLabelKey = function getColorLabelKey(color) {
192
+ var _specFor$labelKey, _specFor;
193
+ return (_specFor$labelKey = (_specFor = specFor(color)) === null || _specFor === void 0 ? void 0 : _specFor.labelKey) !== null && _specFor$labelKey !== void 0 ? _specFor$labelKey : 'neutralColor';
194
+ };
195
+ export var isSwatchSelected = function isSwatchSelected(swatchValue, selectedColor) {
196
+ var _specFor2, _specFor3;
197
+ if (!selectedColor) {
198
+ return false;
199
+ }
200
+ if (normalizeColor(swatchValue) === normalizeColor(selectedColor)) {
201
+ return true;
202
+ }
203
+
204
+ // A swatch also counts as selected when it renders the same hue under a different
205
+ // id — legacy named `green`/`yellow` share the Lime/Orange swatches. Unknown values
206
+ // have no spec, so they never collide on the neutral fallback.
207
+ var swatchAppearance = (_specFor2 = specFor(swatchValue)) === null || _specFor2 === void 0 ? void 0 : _specFor2.appearance;
208
+ return swatchAppearance !== undefined && swatchAppearance === ((_specFor3 = specFor(selectedColor)) === null || _specFor3 === void 0 ? void 0 : _specFor3.appearance);
209
+ };
210
+ export var getLozengeAppearance = function getLozengeAppearance(color) {
211
+ var isUpdateStatusColorsEnabled = UNSAFE_expValNoExposure('platform_editor_update_status_colors', 'isEnabled', false);
212
+
213
+ // Named colours are recoloured only by the experiment. `gracefully_render_status_color`
214
+ // is a read-path gate for hex written by another cohort, so it must never reach here.
215
+ if (isNamedColor(color)) {
216
+ return isUpdateStatusColorsEnabled ? COLORS[color].appearance : colorToLozengeAppearanceMap[color];
217
+ }
218
+ if (isUpdateStatusColorsEnabled || fg('platform_editor_gracefully_render_status_color')) {
219
+ var _specFor$appearance, _specFor4;
220
+ return (_specFor$appearance = (_specFor4 = specFor(color)) === null || _specFor4 === void 0 ? void 0 : _specFor4.appearance) !== null && _specFor$appearance !== void 0 ? _specFor$appearance : DEFAULT_LOZENGE_APPEARANCE;
221
+ }
222
+ return DEFAULT_LOZENGE_APPEARANCE;
223
+ };
@@ -4,7 +4,12 @@
4
4
  */
5
5
  import { type ForwardRefExoticComponent, type RefAttributes } from 'react';
6
6
  import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnalyticsEvents';
7
- export type Color = 'neutral' | 'purple' | 'blue' | 'red' | 'yellow' | 'green';
7
+ import { type NamedColor } from './status-colors';
8
+ /**
9
+ * What the ADF `color` attribute can hold. `HexColor` is the closed set we persist — do
10
+ * not substitute it here, or graceful rendering of unknown hex becomes a type error.
11
+ */
12
+ export type Color = NamedColor | `#${string}`;
8
13
  export type StatusStyle = 'bold' | 'subtle';
9
14
  export interface OwnProps {
10
15
  color: Color;
@@ -2,12 +2,23 @@ import React, { type ReactNode } from 'react';
2
2
  import { type WithIntlProps, type WrappedComponentProps } from 'react-intl';
3
3
  import { type Color } from './Status';
4
4
  export type ColorType = Color;
5
+ /**
6
+ * Which set of selectable values the picker offers.
7
+ * - `default`: the six named colours.
8
+ * - `extended`: ten colours; hues without an existing name are persisted as hex.
9
+ */
10
+ export type StatusPaletteVariant = 'default' | 'extended';
5
11
  export interface Props {
6
12
  autoFocus?: boolean;
7
13
  onColorClick: (value: ColorType) => void;
8
14
  onColorHover?: (value: ColorType) => void;
9
15
  onEnter: () => void;
10
16
  onTextChanged: (value: string) => void;
17
+ /**
18
+ * Which set of selectable colours to offer. Defaults to the six named colours;
19
+ * `extended` offers ten and can emit hex values through `onColorClick`.
20
+ */
21
+ palette?: StatusPaletteVariant;
11
22
  scrollableContent?: ReactNode;
12
23
  selectedColor: ColorType;
13
24
  text: string;
@@ -1,37 +1,57 @@
1
1
  export declare const messages: {
2
- neutralColor: {
3
- id: string;
2
+ blueColor: {
4
3
  defaultMessage: string;
5
4
  description: string;
6
- };
7
- purpleColor: {
8
5
  id: string;
6
+ };
7
+ greenColor: {
9
8
  defaultMessage: string;
10
9
  description: string;
11
- };
12
- blueColor: {
13
10
  id: string;
11
+ };
12
+ limeColor: {
14
13
  defaultMessage: string;
15
14
  description: string;
16
- };
17
- redColor: {
18
15
  id: string;
16
+ };
17
+ magentaColor: {
19
18
  defaultMessage: string;
20
19
  description: string;
20
+ id: string;
21
21
  };
22
- yellowColor: {
22
+ neutralColor: {
23
+ defaultMessage: string;
24
+ description: string;
23
25
  id: string;
26
+ };
27
+ orangeColor: {
24
28
  defaultMessage: string;
25
29
  description: string;
30
+ id: string;
26
31
  };
27
- greenColor: {
32
+ purpleColor: {
33
+ defaultMessage: string;
34
+ description: string;
28
35
  id: string;
36
+ };
37
+ redColor: {
29
38
  defaultMessage: string;
30
39
  description: string;
40
+ id: string;
31
41
  };
32
42
  statusInputLabel: {
43
+ defaultMessage: string;
44
+ description: string;
33
45
  id: string;
46
+ };
47
+ tealColor: {
34
48
  defaultMessage: string;
35
49
  description: string;
50
+ id: string;
51
+ };
52
+ yellowColor: {
53
+ defaultMessage: string;
54
+ description: string;
55
+ id: string;
36
56
  };
37
57
  };
@@ -1,10 +1,13 @@
1
1
  import { type Color as ColorType } from '../Status';
2
+ import { type StatusPaletteVariant } from '../StatusPicker';
2
3
  interface ColorPaletteProps {
3
4
  className?: string;
4
5
  cols?: number;
5
6
  onClick: (value: ColorType) => void;
6
7
  onHover?: (value: ColorType) => void;
8
+ /** Which set of selectable values to offer. Defaults to the six named colours. */
9
+ palette?: StatusPaletteVariant;
7
10
  selectedColor?: ColorType;
8
11
  }
9
12
  export default _default;
10
- declare function _default({ cols, onClick, selectedColor, className, onHover, }: ColorPaletteProps): JSX.Element;
13
+ declare function _default({ cols, onClick, selectedColor, className, onHover, palette: variant, }: ColorPaletteProps): JSX.Element;
@@ -0,0 +1,66 @@
1
+ import type { AccentColor, SemanticColor } from '@atlaskit/lozenge/types';
2
+ /** Named colours the ADF `color` attribute can carry. */
3
+ export type NamedColor = 'neutral' | 'purple' | 'blue' | 'red' | 'yellow' | 'green';
4
+ export declare const NAMED_COLORS: readonly NamedColor[];
5
+ /**
6
+ * Hex ids the picker persists — the hues with no existing named ADF colour.
7
+ * Each is the panel-medium hex for that accent, so it resolves to the same token
8
+ * the editor palette would give it.
9
+ */
10
+ export type HexColor = '#B3F5FF' | '#ABF5D1' | '#D3F1A7' | '#FFF0B3' | '#FCE4A6' | '#FDD0EC';
11
+ export declare const HEX_PALETTE: readonly HexColor[];
12
+ export type PaletteColor = NamedColor | HexColor;
13
+ export declare const DEFAULT_LOZENGE_APPEARANCE: SemanticColor;
14
+ /** Pre-experiment mapping. Delete with `platform_editor_update_status_colors`. */
15
+ export declare const colorToLozengeAppearanceMap: {
16
+ [K in NamedColor]: SemanticColor;
17
+ };
18
+ /**
19
+ * Check-mark colour for the selected swatch. Uniform across the ten-colour palette, so
20
+ * it is not a per-colour field. (The legacy six-colour palette does vary it, which is
21
+ * why `ColorProps` still takes it per swatch.)
22
+ */
23
+ export declare const SWATCH_ICON_COLOR: string;
24
+ /**
25
+ * Keys of `messages` usable as a swatch's accessible name. Kept as a union so
26
+ * `getColorLabelKey` returns something `messages` is guaranteed to have — the
27
+ * call site in `color.tsx` then needs no cast, and an unregistered colour cannot
28
+ * produce a missing key.
29
+ */
30
+ type ColorLabelKey = 'neutralColor' | 'purpleColor' | 'blueColor' | 'redColor' | 'yellowColor' | 'greenColor' | 'tealColor' | 'limeColor' | 'orangeColor' | 'magentaColor';
31
+ type ColorSpec = {
32
+ appearance: SemanticColor | AccentColor;
33
+ /** Key in `messages` for the picker swatch's accessible name. */
34
+ labelKey: ColorLabelKey;
35
+ /** Present when the colour is offered as a swatch in the ten-colour picker. */
36
+ swatch?: {
37
+ backgroundColor: string;
38
+ borderColor: string;
39
+ };
40
+ };
41
+ /**
42
+ * Single source of truth for status colours: appearance, swatch tokens and i18n key.
43
+ * Typed as a total `Record`, so adding a value to NAMED_COLORS or HEX_PALETTE
44
+ * fails to compile until it is described here.
45
+ *
46
+ * Legacy named `yellow`/`green` have no swatch — they are not offered separately,
47
+ * because `accent-orange`/`accent-lime` are byte-identical to the Orange/Lime swatches
48
+ * in both themes. The distinct Yellow and Green swatches are the #FFF0B3 / #ABF5D1 hues.
49
+ *
50
+ * CSS cannot be derived from this: Compiled needs static literals and the styling lint
51
+ * rule rejects computed values. `statusStylesHexAccent` in editor-core mirrors it by hand.
52
+ */
53
+ export declare const COLORS: Record<PaletteColor, ColorSpec>;
54
+ /** Swatch order in the ten-colour picker: two rows of five. */
55
+ export declare const PICKER_SWATCHES: readonly PaletteColor[];
56
+ export declare const isNamedColor: (color: string) => color is NamedColor;
57
+ export declare const normalizeColor: (color: string) => string;
58
+ /**
59
+ * Falls back to the neutral label rather than building a key from the colour: an
60
+ * unregistered value would otherwise yield a key `messages` does not have, and
61
+ * spreading the resulting `undefined` into `FormattedMessage` throws.
62
+ */
63
+ export declare const getColorLabelKey: (color: string) => ColorLabelKey;
64
+ export declare const isSwatchSelected: (swatchValue: string, selectedColor?: string) => boolean;
65
+ export declare const getLozengeAppearance: (color: string) => SemanticColor | AccentColor;
66
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/status",
3
- "version": "5.10.0",
3
+ "version": "5.11.0",
4
4
  "description": "Fabric Status React Components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,6 +29,7 @@
29
29
  "devDependencies": {
30
30
  "@af/visual-regression": "workspace:^",
31
31
  "@atlassian/a11y-jest-testing": "^0.17.0",
32
+ "@atlassian/experiment-test-utils": "^0.2.0",
32
33
  "@atlassian/feature-flags-test-utils": "^1.3.0",
33
34
  "@atlassian/workbench": "workspace:*",
34
35
  "@testing-library/jest-dom": "^6.4.5",
@@ -47,11 +48,12 @@
47
48
  "@atlaskit/analytics-next": "^12.5.0",
48
49
  "@atlaskit/icon": "^37.6.0",
49
50
  "@atlaskit/lozenge": "^15.4.0",
51
+ "@atlaskit/platform-feature-experiments": "^0.3.0",
50
52
  "@atlaskit/platform-feature-flags": "^2.2.0",
51
53
  "@atlaskit/primitives": "^22.5.0",
52
54
  "@atlaskit/react-compiler-gating": "^0.2.0",
53
55
  "@atlaskit/textfield": "^10.2.0",
54
- "@atlaskit/tmp-editor-statsig": "^190.0.0",
56
+ "@atlaskit/tmp-editor-statsig": "^192.0.0",
55
57
  "@atlaskit/tokens": "^16.12.0",
56
58
  "@babel/runtime": "^7.0.0",
57
59
  "@compiled/react": "^1.0.2"
@@ -72,6 +74,9 @@
72
74
  },
73
75
  "platform-dst-lozenge-tag-badge-visual-uplifts": {
74
76
  "type": "boolean"
77
+ },
78
+ "platform_editor_gracefully_render_status_color": {
79
+ "type": "boolean"
75
80
  }
76
81
  }
77
82
  }