@atlaskit/color-picker 3.3.1 → 3.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/color-picker
2
2
 
3
+ ## 3.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#141841](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/141841)
8
+ [`c47656cb21bcc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c47656cb21bcc) -
9
+ Clean up color palette menu A11y FG
10
+
3
11
  ## 3.3.1
4
12
 
5
13
  ### Patch Changes
@@ -26,7 +26,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
26
26
 
27
27
  var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRef) {
28
28
  var type = props.type,
29
+ _props$autoFocus = props.autoFocus,
30
+ autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,
29
31
  initialFocusRef = props.initialFocusRef,
32
+ _props$isInsideMenu = props.isInsideMenu,
33
+ isInsideMenu = _props$isInsideMenu === void 0 ? true : _props$isInsideMenu,
30
34
  value = props.value,
31
35
  label = props.label,
32
36
  selected = props.selected,
@@ -40,7 +44,6 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
40
44
  var ref = (0, _react.useRef)(null);
41
45
  var isInitialFocus = (0, _react.useRef)(true);
42
46
  var isColorPaletteMenu = type === _constants.COLOR_PALETTE_MENU;
43
- var isTabbingIgnored = (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') ? isColorPaletteMenu : false;
44
47
  var handleMouseDown = (0, _react.useCallback)(function (event) {
45
48
  event.preventDefault();
46
49
  }, []);
@@ -58,7 +61,7 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
58
61
  }
59
62
  }, [onClick, onClickOld, value]);
60
63
  var handleKeyDown = (0, _react.useCallback)(function (event) {
61
- if ((isTabbingIgnored || isTabbing === undefined || isTabbing) && (onClickOld && !(0, _platformFeatureFlags.fg)('platform_color_palette-expose-event') || onClick && (0, _platformFeatureFlags.fg)('platform_color_palette-expose-event')) && (event.key === _constants.KEY_ENTER || event.key === _constants.KEY_SPACE)) {
64
+ if ((isColorPaletteMenu || isTabbing === undefined || isTabbing) && (onClickOld && !(0, _platformFeatureFlags.fg)('platform_color_palette-expose-event') || onClick && (0, _platformFeatureFlags.fg)('platform_color_palette-expose-event')) && (event.key === _constants.KEY_ENTER || event.key === _constants.KEY_SPACE)) {
62
65
  event.preventDefault();
63
66
  if (isTabbing) {
64
67
  event.stopPropagation();
@@ -67,37 +70,20 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
67
70
  // Remove optional call on FG cleanup platform_color_palette-expose-event
68
71
  (0, _platformFeatureFlags.fg)('platform_color_palette-expose-event') ? onClick === null || onClick === void 0 ? void 0 : onClick(event, value) : onClickOld === null || onClickOld === void 0 ? void 0 : onClickOld(value);
69
72
  }
70
- if ((0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y')) {
71
- if (isColorPaletteMenu) {
72
- onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
73
- } else if (event.key === _constants.KEY_TAB) {
74
- event.stopPropagation();
75
- event.preventDefault();
76
- }
77
- }
78
- }, [isTabbingIgnored, isTabbing, onClick, onClickOld, value, isColorPaletteMenu, onKeyDown]);
79
- (0, _react.useEffect)(function () {
80
- if (!(0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y')) {
81
- var refCurrent = ref.current;
82
- var handleTabKey = function handleTabKey(event) {
83
- if (event.key === _constants.KEY_TAB) {
84
- event.stopPropagation();
85
- event.preventDefault();
86
- }
87
- };
88
- refCurrent === null || refCurrent === void 0 || refCurrent.addEventListener('keydown', handleTabKey);
89
- return function () {
90
- refCurrent === null || refCurrent === void 0 || refCurrent.removeEventListener('keydown', handleTabKey);
91
- };
73
+ if (isColorPaletteMenu) {
74
+ onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
75
+ } else if (event.key === _constants.KEY_TAB) {
76
+ event.preventDefault();
77
+ event.stopPropagation();
92
78
  }
93
- }, []);
79
+ }, [isColorPaletteMenu, isTabbing, value, onClick, onClickOld, onKeyDown]);
94
80
  (0, _react.useImperativeHandle)(componentRef, function () {
95
81
  return {
96
82
  focus: function focus() {
97
- if (isTabbingIgnored) {
83
+ if (isColorPaletteMenu) {
98
84
  if (isInitialFocus.current) {
99
85
  var _ref$current;
100
- !initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
86
+ autoFocus && !initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
101
87
  isInitialFocus.current = false;
102
88
  } else {
103
89
  var _ref$current2;
@@ -106,18 +92,18 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
106
92
  }
107
93
  }
108
94
  };
109
- }, [isTabbingIgnored, initialFocusRef]);
95
+ }, [autoFocus, isColorPaletteMenu, initialFocusRef]);
110
96
  return (0, _react2.jsx)(_tooltip.default, {
111
97
  content: label
112
98
  }, function (tooltipProps) {
113
99
  delete tooltipProps['aria-describedby'];
114
100
  return (0, _react2.jsx)("div", (0, _extends2.default)({}, tooltipProps, {
115
101
  ref: initialFocusRef ? (0, _useCallbackRef.mergeRefs)([ref, tooltipProps.ref, initialFocusRef]) : (0, _useCallbackRef.mergeRefs)([ref, tooltipProps.ref]),
116
- role: (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') ? 'menuitemradio' : 'radio',
117
- tabIndex: (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') ? selected ? 0 : -1 : 0,
102
+ role: isInsideMenu ? 'menuitemradio' : 'radio',
103
+ tabIndex: selected ? 0 : -1,
118
104
  "aria-checked": selected,
119
105
  "aria-label": label,
120
- css: [sharedColorContainerStyles, (isTabbingIgnored || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isTabbingIgnored || !isTabbing) && colorCardOptionFocusedStyles],
106
+ css: [sharedColorContainerStyles, (isColorPaletteMenu || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isColorPaletteMenu || !isTabbing) && colorCardOptionFocusedStyles],
121
107
  onClick: handleClick,
122
108
  onMouseDown: handleMouseDown,
123
109
  onKeyDown: handleKeyDown
@@ -24,8 +24,12 @@ var _colors = require("@atlaskit/theme/colors");
24
24
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
 
26
26
  var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAnalytics(_ref) {
27
- var _ref$isFocusLockEnabl = _ref.isFocusLockEnabled,
27
+ var _ref$autoFocus = _ref.autoFocus,
28
+ autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
29
+ _ref$isFocusLockEnabl = _ref.isFocusLockEnabled,
28
30
  isFocusLockEnabled = _ref$isFocusLockEnabl === void 0 ? true : _ref$isFocusLockEnabl,
31
+ _ref$isInsideMenu = _ref.isInsideMenu,
32
+ isInsideMenu = _ref$isInsideMenu === void 0 ? true : _ref$isInsideMenu,
29
33
  createAnalyticsEvent = _ref.createAnalyticsEvent,
30
34
  onChange = _ref.onChange,
31
35
  onChangeOld = _ref.onChangeOld,
@@ -60,7 +64,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
60
64
  attributes: {
61
65
  componentName: 'color-picker',
62
66
  packageName: "@atlaskit/color-picker",
63
- packageVersion: "3.3.1"
67
+ packageVersion: "3.3.2"
64
68
  }
65
69
  })(createAnalyticsEvent);
66
70
  }
@@ -110,7 +114,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
110
114
  }, [isFocusLockEnabled, selectedColorIndex, setFocusedIndex, options]);
111
115
  return (0, _react2.jsx)("div", {
112
116
  "aria-label": fullLabel,
113
- role: (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup'
117
+ role: isInsideMenu ? 'group' : 'radiogroup'
114
118
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
115
119
  ,
116
120
  css: [colorPaletteMenuStyles, mode === _types.Mode.Standard && colorPaletteMenuStandardStyles],
@@ -139,11 +143,13 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
139
143
  onClick: handleChange
140
144
  } : {
141
145
  onClickOld: handleChangeOld
142
- }, (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') && {
146
+ }, {
143
147
  ref: function ref(_ref4) {
144
148
  colorCardRefs[index] = _ref4;
145
149
  },
150
+ autoFocus: autoFocus,
146
151
  initialFocusRef: value === selectedValue.value ? initialFocusRef : undefined,
152
+ isInsideMenu: isInsideMenu,
147
153
  onKeyDown: handleKeyDown
148
154
  })));
149
155
  })));
@@ -151,7 +157,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
151
157
  var _default = exports.default = (0, _analyticsNext.withAnalyticsContext)({
152
158
  componentName: 'color-picker',
153
159
  packageName: "@atlaskit/color-picker",
154
- packageVersion: "3.3.1"
160
+ packageVersion: "3.3.2"
155
161
  })((0, _analyticsNext.withAnalyticsEvents)()(ColorPaletteMenuWithoutAnalytics));
156
162
  var colorCardWrapperStyles = (0, _react2.css)({
157
163
  display: 'flex',
@@ -42,7 +42,7 @@ var defaultPopperProps = {
42
42
  placement: 'bottom-start'
43
43
  };
44
44
  var packageName = "@atlaskit/color-picker";
45
- var packageVersion = "3.3.1";
45
+ var packageVersion = "3.3.2";
46
46
  var ColorPickerWithoutAnalyticsBase = /*#__PURE__*/function (_React$Component) {
47
47
  (0, _inherits2.default)(ColorPickerWithoutAnalyticsBase, _React$Component);
48
48
  var _super = _createSuper(ColorPickerWithoutAnalyticsBase);
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.Placeholder = exports.Option = exports.MenuList = exports.DropdownIndicator = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
9
  var _ColorCard = _interopRequireDefault(require("./ColorCard"));
11
10
  var _utils = require("../utils");
12
11
  var _react = require("@emotion/react");
@@ -24,7 +23,7 @@ var MenuList = exports.MenuList = function MenuList(props) {
24
23
  children = props.children;
25
24
  return (0, _react.jsx)("div", {
26
25
  css: colorPaletteContainerStyles,
27
- role: (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup',
26
+ role: "group",
28
27
  style: {
29
28
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
30
29
  maxWidth: cols ? (0, _utils.getWidth)(cols) : undefined
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  * @jsxRuntime classic
4
4
  * @jsx jsx
5
5
  */
6
- import React, { useCallback, useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
6
+ import React, { useCallback, useRef, useImperativeHandle, forwardRef } from 'react';
7
7
  import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
8
8
  import Tooltip from '@atlaskit/tooltip';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -15,7 +15,9 @@ import { mergeRefs } from 'use-callback-ref';
15
15
  const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
16
16
  const {
17
17
  type,
18
+ autoFocus = true,
18
19
  initialFocusRef,
20
+ isInsideMenu = true,
19
21
  value,
20
22
  label,
21
23
  selected,
@@ -29,7 +31,6 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
29
31
  const ref = useRef(null);
30
32
  const isInitialFocus = useRef(true);
31
33
  const isColorPaletteMenu = type === COLOR_PALETTE_MENU;
32
- const isTabbingIgnored = fg('platform_color_palette_menu_timeline_bar_a11y') ? isColorPaletteMenu : false;
33
34
  const handleMouseDown = useCallback(event => {
34
35
  event.preventDefault();
35
36
  }, []);
@@ -47,7 +48,7 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
47
48
  }
48
49
  }, [onClick, onClickOld, value]);
49
50
  const handleKeyDown = useCallback(event => {
50
- if ((isTabbingIgnored || isTabbing === undefined || isTabbing) && (onClickOld && !fg('platform_color_palette-expose-event') || onClick && fg('platform_color_palette-expose-event')) && (event.key === KEY_ENTER || event.key === KEY_SPACE)) {
51
+ if ((isColorPaletteMenu || isTabbing === undefined || isTabbing) && (onClickOld && !fg('platform_color_palette-expose-event') || onClick && fg('platform_color_palette-expose-event')) && (event.key === KEY_ENTER || event.key === KEY_SPACE)) {
51
52
  event.preventDefault();
52
53
  if (isTabbing) {
53
54
  event.stopPropagation();
@@ -56,36 +57,19 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
56
57
  // Remove optional call on FG cleanup platform_color_palette-expose-event
57
58
  fg('platform_color_palette-expose-event') ? onClick === null || onClick === void 0 ? void 0 : onClick(event, value) : onClickOld === null || onClickOld === void 0 ? void 0 : onClickOld(value);
58
59
  }
59
- if (fg('platform_color_palette_menu_timeline_bar_a11y')) {
60
- if (isColorPaletteMenu) {
61
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
62
- } else if (event.key === KEY_TAB) {
63
- event.stopPropagation();
64
- event.preventDefault();
65
- }
66
- }
67
- }, [isTabbingIgnored, isTabbing, onClick, onClickOld, value, isColorPaletteMenu, onKeyDown]);
68
- useEffect(() => {
69
- if (!fg('platform_color_palette_menu_timeline_bar_a11y')) {
70
- const refCurrent = ref.current;
71
- const handleTabKey = event => {
72
- if (event.key === KEY_TAB) {
73
- event.stopPropagation();
74
- event.preventDefault();
75
- }
76
- };
77
- refCurrent === null || refCurrent === void 0 ? void 0 : refCurrent.addEventListener('keydown', handleTabKey);
78
- return () => {
79
- refCurrent === null || refCurrent === void 0 ? void 0 : refCurrent.removeEventListener('keydown', handleTabKey);
80
- };
60
+ if (isColorPaletteMenu) {
61
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
62
+ } else if (event.key === KEY_TAB) {
63
+ event.preventDefault();
64
+ event.stopPropagation();
81
65
  }
82
- }, []);
66
+ }, [isColorPaletteMenu, isTabbing, value, onClick, onClickOld, onKeyDown]);
83
67
  useImperativeHandle(componentRef, () => ({
84
68
  focus: () => {
85
- if (isTabbingIgnored) {
69
+ if (isColorPaletteMenu) {
86
70
  if (isInitialFocus.current) {
87
71
  var _ref$current;
88
- !initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
72
+ autoFocus && !initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
89
73
  isInitialFocus.current = false;
90
74
  } else {
91
75
  var _ref$current2;
@@ -93,18 +77,18 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
93
77
  }
94
78
  }
95
79
  }
96
- }), [isTabbingIgnored, initialFocusRef]);
80
+ }), [autoFocus, isColorPaletteMenu, initialFocusRef]);
97
81
  return jsx(Tooltip, {
98
82
  content: label
99
83
  }, tooltipProps => {
100
84
  delete tooltipProps['aria-describedby'];
101
85
  return jsx("div", _extends({}, tooltipProps, {
102
86
  ref: initialFocusRef ? mergeRefs([ref, tooltipProps.ref, initialFocusRef]) : mergeRefs([ref, tooltipProps.ref]),
103
- role: fg('platform_color_palette_menu_timeline_bar_a11y') ? 'menuitemradio' : 'radio',
104
- tabIndex: fg('platform_color_palette_menu_timeline_bar_a11y') ? selected ? 0 : -1 : 0,
87
+ role: isInsideMenu ? 'menuitemradio' : 'radio',
88
+ tabIndex: selected ? 0 : -1,
105
89
  "aria-checked": selected,
106
90
  "aria-label": label,
107
- css: [sharedColorContainerStyles, (isTabbingIgnored || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isTabbingIgnored || !isTabbing) && colorCardOptionFocusedStyles],
91
+ css: [sharedColorContainerStyles, (isColorPaletteMenu || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isColorPaletteMenu || !isTabbing) && colorCardOptionFocusedStyles],
108
92
  onClick: handleClick,
109
93
  onMouseDown: handleMouseDown,
110
94
  onKeyDown: handleKeyDown
@@ -14,7 +14,9 @@ import { css, jsx } from '@emotion/react';
14
14
  import { COLOR_PALETTE_MENU, KEY_ARROW_UP, KEY_ARROW_DOWN, KEY_ARROW_LEFT, KEY_ARROW_RIGHT, KEY_TAB } from '../constants';
15
15
  import { N0, N40 } from '@atlaskit/theme/colors';
16
16
  export const ColorPaletteMenuWithoutAnalytics = ({
17
+ autoFocus = true,
17
18
  isFocusLockEnabled = true,
19
+ isInsideMenu = true,
18
20
  createAnalyticsEvent,
19
21
  onChange,
20
22
  onChangeOld,
@@ -44,7 +46,7 @@ export const ColorPaletteMenuWithoutAnalytics = ({
44
46
  attributes: {
45
47
  componentName: 'color-picker',
46
48
  packageName: "@atlaskit/color-picker",
47
- packageVersion: "3.3.1"
49
+ packageVersion: "3.3.2"
48
50
  }
49
51
  })(createAnalyticsEvent);
50
52
  }
@@ -88,7 +90,7 @@ export const ColorPaletteMenuWithoutAnalytics = ({
88
90
  }, [isFocusLockEnabled, selectedColorIndex, setFocusedIndex, options]);
89
91
  return jsx("div", {
90
92
  "aria-label": fullLabel,
91
- role: fg('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup'
93
+ role: isInsideMenu ? 'group' : 'radiogroup'
92
94
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
93
95
  ,
94
96
  css: [colorPaletteMenuStyles, mode === Mode.Standard && colorPaletteMenuStandardStyles],
@@ -117,18 +119,20 @@ export const ColorPaletteMenuWithoutAnalytics = ({
117
119
  onClick: handleChange
118
120
  } : {
119
121
  onClickOld: handleChangeOld
120
- }, fg('platform_color_palette_menu_timeline_bar_a11y') && {
122
+ }, {
121
123
  ref: ref => {
122
124
  colorCardRefs[index] = ref;
123
125
  },
126
+ autoFocus: autoFocus,
124
127
  initialFocusRef: value === selectedValue.value ? initialFocusRef : undefined,
128
+ isInsideMenu: isInsideMenu,
125
129
  onKeyDown: handleKeyDown
126
130
  }))))));
127
131
  };
128
132
  export default withAnalyticsContext({
129
133
  componentName: 'color-picker',
130
134
  packageName: "@atlaskit/color-picker",
131
- packageVersion: "3.3.1"
135
+ packageVersion: "3.3.2"
132
136
  })(withAnalyticsEvents()(ColorPaletteMenuWithoutAnalytics));
133
137
  const colorCardWrapperStyles = css({
134
138
  display: 'flex',
@@ -26,7 +26,7 @@ const defaultPopperProps = {
26
26
  placement: 'bottom-start'
27
27
  };
28
28
  const packageName = "@atlaskit/color-picker";
29
- const packageVersion = "3.3.1";
29
+ const packageVersion = "3.3.2";
30
30
  class ColorPickerWithoutAnalyticsBase extends React.Component {
31
31
  constructor(...args) {
32
32
  super(...args);
@@ -4,7 +4,6 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  * @jsx jsx
5
5
  */
6
6
 
7
- import { fg } from '@atlaskit/platform-feature-flags';
8
7
  import ColorCard from './ColorCard';
9
8
  import { getWidth } from '../utils';
10
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
@@ -20,7 +19,7 @@ export const MenuList = props => {
20
19
  } = props;
21
20
  return jsx("div", {
22
21
  css: colorPaletteContainerStyles,
23
- role: fg('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup',
22
+ role: "group",
24
23
  style: {
25
24
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
26
25
  maxWidth: cols ? getWidth(cols) : undefined
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  * @jsxRuntime classic
4
4
  * @jsx jsx
5
5
  */
6
- import React, { useCallback, useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
6
+ import React, { useCallback, useRef, useImperativeHandle, forwardRef } from 'react';
7
7
  import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
8
8
  import Tooltip from '@atlaskit/tooltip';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -14,7 +14,11 @@ import { N0, DN600A, B75 } from '@atlaskit/theme/colors';
14
14
  import { mergeRefs } from 'use-callback-ref';
15
15
  var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
16
16
  var type = props.type,
17
+ _props$autoFocus = props.autoFocus,
18
+ autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,
17
19
  initialFocusRef = props.initialFocusRef,
20
+ _props$isInsideMenu = props.isInsideMenu,
21
+ isInsideMenu = _props$isInsideMenu === void 0 ? true : _props$isInsideMenu,
18
22
  value = props.value,
19
23
  label = props.label,
20
24
  selected = props.selected,
@@ -28,7 +32,6 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
28
32
  var ref = useRef(null);
29
33
  var isInitialFocus = useRef(true);
30
34
  var isColorPaletteMenu = type === COLOR_PALETTE_MENU;
31
- var isTabbingIgnored = fg('platform_color_palette_menu_timeline_bar_a11y') ? isColorPaletteMenu : false;
32
35
  var handleMouseDown = useCallback(function (event) {
33
36
  event.preventDefault();
34
37
  }, []);
@@ -46,7 +49,7 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
46
49
  }
47
50
  }, [onClick, onClickOld, value]);
48
51
  var handleKeyDown = useCallback(function (event) {
49
- if ((isTabbingIgnored || isTabbing === undefined || isTabbing) && (onClickOld && !fg('platform_color_palette-expose-event') || onClick && fg('platform_color_palette-expose-event')) && (event.key === KEY_ENTER || event.key === KEY_SPACE)) {
52
+ if ((isColorPaletteMenu || isTabbing === undefined || isTabbing) && (onClickOld && !fg('platform_color_palette-expose-event') || onClick && fg('platform_color_palette-expose-event')) && (event.key === KEY_ENTER || event.key === KEY_SPACE)) {
50
53
  event.preventDefault();
51
54
  if (isTabbing) {
52
55
  event.stopPropagation();
@@ -55,37 +58,20 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
55
58
  // Remove optional call on FG cleanup platform_color_palette-expose-event
56
59
  fg('platform_color_palette-expose-event') ? onClick === null || onClick === void 0 ? void 0 : onClick(event, value) : onClickOld === null || onClickOld === void 0 ? void 0 : onClickOld(value);
57
60
  }
58
- if (fg('platform_color_palette_menu_timeline_bar_a11y')) {
59
- if (isColorPaletteMenu) {
60
- onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
61
- } else if (event.key === KEY_TAB) {
62
- event.stopPropagation();
63
- event.preventDefault();
64
- }
65
- }
66
- }, [isTabbingIgnored, isTabbing, onClick, onClickOld, value, isColorPaletteMenu, onKeyDown]);
67
- useEffect(function () {
68
- if (!fg('platform_color_palette_menu_timeline_bar_a11y')) {
69
- var refCurrent = ref.current;
70
- var handleTabKey = function handleTabKey(event) {
71
- if (event.key === KEY_TAB) {
72
- event.stopPropagation();
73
- event.preventDefault();
74
- }
75
- };
76
- refCurrent === null || refCurrent === void 0 || refCurrent.addEventListener('keydown', handleTabKey);
77
- return function () {
78
- refCurrent === null || refCurrent === void 0 || refCurrent.removeEventListener('keydown', handleTabKey);
79
- };
61
+ if (isColorPaletteMenu) {
62
+ onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
63
+ } else if (event.key === KEY_TAB) {
64
+ event.preventDefault();
65
+ event.stopPropagation();
80
66
  }
81
- }, []);
67
+ }, [isColorPaletteMenu, isTabbing, value, onClick, onClickOld, onKeyDown]);
82
68
  useImperativeHandle(componentRef, function () {
83
69
  return {
84
70
  focus: function focus() {
85
- if (isTabbingIgnored) {
71
+ if (isColorPaletteMenu) {
86
72
  if (isInitialFocus.current) {
87
73
  var _ref$current;
88
- !initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
74
+ autoFocus && !initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
89
75
  isInitialFocus.current = false;
90
76
  } else {
91
77
  var _ref$current2;
@@ -94,18 +80,18 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
94
80
  }
95
81
  }
96
82
  };
97
- }, [isTabbingIgnored, initialFocusRef]);
83
+ }, [autoFocus, isColorPaletteMenu, initialFocusRef]);
98
84
  return jsx(Tooltip, {
99
85
  content: label
100
86
  }, function (tooltipProps) {
101
87
  delete tooltipProps['aria-describedby'];
102
88
  return jsx("div", _extends({}, tooltipProps, {
103
89
  ref: initialFocusRef ? mergeRefs([ref, tooltipProps.ref, initialFocusRef]) : mergeRefs([ref, tooltipProps.ref]),
104
- role: fg('platform_color_palette_menu_timeline_bar_a11y') ? 'menuitemradio' : 'radio',
105
- tabIndex: fg('platform_color_palette_menu_timeline_bar_a11y') ? selected ? 0 : -1 : 0,
90
+ role: isInsideMenu ? 'menuitemradio' : 'radio',
91
+ tabIndex: selected ? 0 : -1,
106
92
  "aria-checked": selected,
107
93
  "aria-label": label,
108
- css: [sharedColorContainerStyles, (isTabbingIgnored || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isTabbingIgnored || !isTabbing) && colorCardOptionFocusedStyles],
94
+ css: [sharedColorContainerStyles, (isColorPaletteMenu || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isColorPaletteMenu || !isTabbing) && colorCardOptionFocusedStyles],
109
95
  onClick: handleClick,
110
96
  onMouseDown: handleMouseDown,
111
97
  onKeyDown: handleKeyDown
@@ -15,8 +15,12 @@ import { css, jsx } from '@emotion/react';
15
15
  import { COLOR_PALETTE_MENU, KEY_ARROW_UP, KEY_ARROW_DOWN, KEY_ARROW_LEFT, KEY_ARROW_RIGHT, KEY_TAB } from '../constants';
16
16
  import { N0, N40 } from '@atlaskit/theme/colors';
17
17
  export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAnalytics(_ref) {
18
- var _ref$isFocusLockEnabl = _ref.isFocusLockEnabled,
18
+ var _ref$autoFocus = _ref.autoFocus,
19
+ autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
20
+ _ref$isFocusLockEnabl = _ref.isFocusLockEnabled,
19
21
  isFocusLockEnabled = _ref$isFocusLockEnabl === void 0 ? true : _ref$isFocusLockEnabl,
22
+ _ref$isInsideMenu = _ref.isInsideMenu,
23
+ isInsideMenu = _ref$isInsideMenu === void 0 ? true : _ref$isInsideMenu,
20
24
  createAnalyticsEvent = _ref.createAnalyticsEvent,
21
25
  onChange = _ref.onChange,
22
26
  onChangeOld = _ref.onChangeOld,
@@ -51,7 +55,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
51
55
  attributes: {
52
56
  componentName: 'color-picker',
53
57
  packageName: "@atlaskit/color-picker",
54
- packageVersion: "3.3.1"
58
+ packageVersion: "3.3.2"
55
59
  }
56
60
  })(createAnalyticsEvent);
57
61
  }
@@ -101,7 +105,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
101
105
  }, [isFocusLockEnabled, selectedColorIndex, setFocusedIndex, options]);
102
106
  return jsx("div", {
103
107
  "aria-label": fullLabel,
104
- role: fg('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup'
108
+ role: isInsideMenu ? 'group' : 'radiogroup'
105
109
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
106
110
  ,
107
111
  css: [colorPaletteMenuStyles, mode === Mode.Standard && colorPaletteMenuStandardStyles],
@@ -130,11 +134,13 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
130
134
  onClick: handleChange
131
135
  } : {
132
136
  onClickOld: handleChangeOld
133
- }, fg('platform_color_palette_menu_timeline_bar_a11y') && {
137
+ }, {
134
138
  ref: function ref(_ref4) {
135
139
  colorCardRefs[index] = _ref4;
136
140
  },
141
+ autoFocus: autoFocus,
137
142
  initialFocusRef: value === selectedValue.value ? initialFocusRef : undefined,
143
+ isInsideMenu: isInsideMenu,
138
144
  onKeyDown: handleKeyDown
139
145
  })));
140
146
  })));
@@ -142,7 +148,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
142
148
  export default withAnalyticsContext({
143
149
  componentName: 'color-picker',
144
150
  packageName: "@atlaskit/color-picker",
145
- packageVersion: "3.3.1"
151
+ packageVersion: "3.3.2"
146
152
  })(withAnalyticsEvents()(ColorPaletteMenuWithoutAnalytics));
147
153
  var colorCardWrapperStyles = css({
148
154
  display: 'flex',
@@ -34,7 +34,7 @@ var defaultPopperProps = {
34
34
  placement: 'bottom-start'
35
35
  };
36
36
  var packageName = "@atlaskit/color-picker";
37
- var packageVersion = "3.3.1";
37
+ var packageVersion = "3.3.2";
38
38
  var ColorPickerWithoutAnalyticsBase = /*#__PURE__*/function (_React$Component) {
39
39
  _inherits(ColorPickerWithoutAnalyticsBase, _React$Component);
40
40
  var _super = _createSuper(ColorPickerWithoutAnalyticsBase);
@@ -4,7 +4,6 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  * @jsx jsx
5
5
  */
6
6
 
7
- import { fg } from '@atlaskit/platform-feature-flags';
8
7
  import ColorCard from './ColorCard';
9
8
  import { getWidth } from '../utils';
10
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
@@ -16,7 +15,7 @@ export var MenuList = function MenuList(props) {
16
15
  children = props.children;
17
16
  return jsx("div", {
18
17
  css: colorPaletteContainerStyles,
19
- role: fg('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup',
18
+ role: "group",
20
19
  style: {
21
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
22
21
  maxWidth: cols ? getWidth(cols) : undefined
@@ -5,7 +5,9 @@
5
5
  import React, { type KeyboardEventHandler, type Ref } from 'react';
6
6
  import type { ColorCardType } from '../types';
7
7
  export interface Props {
8
+ autoFocus?: boolean;
8
9
  initialFocusRef?: Ref<HTMLDivElement>;
10
+ isInsideMenu?: boolean;
9
11
  type: ColorCardType;
10
12
  value: string;
11
13
  label: string;
@@ -7,8 +7,12 @@ import { Mode, type Palette } from '../types';
7
7
  import { type UIAnalyticsEvent } from '@atlaskit/analytics-next';
8
8
  import { jsx } from '@emotion/react';
9
9
  export type Props = {
10
+ /** the toggle that decides if the selected color will be automatically focused on load */
11
+ autoFocus?: boolean;
10
12
  /** the toggle that decides if users can tab outside the color picker (arrow keys will always cycle the focus) */
11
13
  isFocusLockEnabled?: boolean;
14
+ /** the toggle that decides if menu-related assistive technology should be applied */
15
+ isInsideMenu?: boolean;
12
16
  /** color picker button label */
13
17
  label?: string;
14
18
  /** list of available colors */
@@ -30,6 +34,6 @@ export type Props = {
30
34
  /** the ref object (usually the currently selected color palette) that consumer can leverage to focus on load */
31
35
  initialFocusRef?: Ref<HTMLDivElement>;
32
36
  };
33
- export declare const ColorPaletteMenuWithoutAnalytics: ({ isFocusLockEnabled, createAnalyticsEvent, onChange, onChangeOld, palette, selectedColor, checkMarkColor, label, cols, mode, initialFocusRef, }: Props) => jsx.JSX.Element;
34
- declare const _default: import("react").ForwardRefExoticComponent<Pick<Omit<Props, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "label" | "analyticsContext" | "key" | "onChange" | "initialFocusRef" | "checkMarkColor" | "cols" | "palette" | "selectedColor" | "isFocusLockEnabled" | "onChangeOld" | "mode"> & import("react").RefAttributes<any>>;
37
+ export declare const ColorPaletteMenuWithoutAnalytics: ({ autoFocus, isFocusLockEnabled, isInsideMenu, createAnalyticsEvent, onChange, onChangeOld, palette, selectedColor, checkMarkColor, label, cols, mode, initialFocusRef, }: Props) => jsx.JSX.Element;
38
+ declare const _default: import("react").ForwardRefExoticComponent<Pick<Omit<Props, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "label" | "analyticsContext" | "key" | "autoFocus" | "onChange" | "initialFocusRef" | "isInsideMenu" | "checkMarkColor" | "cols" | "palette" | "selectedColor" | "isFocusLockEnabled" | "onChangeOld" | "mode"> & import("react").RefAttributes<any>>;
35
39
  export default _default;
@@ -5,7 +5,9 @@
5
5
  import React, { type KeyboardEventHandler, type Ref } from 'react';
6
6
  import type { ColorCardType } from '../types';
7
7
  export interface Props {
8
+ autoFocus?: boolean;
8
9
  initialFocusRef?: Ref<HTMLDivElement>;
10
+ isInsideMenu?: boolean;
9
11
  type: ColorCardType;
10
12
  value: string;
11
13
  label: string;
@@ -7,8 +7,12 @@ import { Mode, type Palette } from '../types';
7
7
  import { type UIAnalyticsEvent } from '@atlaskit/analytics-next';
8
8
  import { jsx } from '@emotion/react';
9
9
  export type Props = {
10
+ /** the toggle that decides if the selected color will be automatically focused on load */
11
+ autoFocus?: boolean;
10
12
  /** the toggle that decides if users can tab outside the color picker (arrow keys will always cycle the focus) */
11
13
  isFocusLockEnabled?: boolean;
14
+ /** the toggle that decides if menu-related assistive technology should be applied */
15
+ isInsideMenu?: boolean;
12
16
  /** color picker button label */
13
17
  label?: string;
14
18
  /** list of available colors */
@@ -30,6 +34,6 @@ export type Props = {
30
34
  /** the ref object (usually the currently selected color palette) that consumer can leverage to focus on load */
31
35
  initialFocusRef?: Ref<HTMLDivElement>;
32
36
  };
33
- export declare const ColorPaletteMenuWithoutAnalytics: ({ isFocusLockEnabled, createAnalyticsEvent, onChange, onChangeOld, palette, selectedColor, checkMarkColor, label, cols, mode, initialFocusRef, }: Props) => jsx.JSX.Element;
34
- declare const _default: import("react").ForwardRefExoticComponent<Pick<Omit<Props, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "label" | "analyticsContext" | "key" | "onChange" | "initialFocusRef" | "checkMarkColor" | "cols" | "palette" | "selectedColor" | "isFocusLockEnabled" | "onChangeOld" | "mode"> & import("react").RefAttributes<any>>;
37
+ export declare const ColorPaletteMenuWithoutAnalytics: ({ autoFocus, isFocusLockEnabled, isInsideMenu, createAnalyticsEvent, onChange, onChangeOld, palette, selectedColor, checkMarkColor, label, cols, mode, initialFocusRef, }: Props) => jsx.JSX.Element;
38
+ declare const _default: import("react").ForwardRefExoticComponent<Pick<Omit<Props, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "label" | "analyticsContext" | "key" | "autoFocus" | "onChange" | "initialFocusRef" | "isInsideMenu" | "checkMarkColor" | "cols" | "palette" | "selectedColor" | "isFocusLockEnabled" | "onChangeOld" | "mode"> & import("react").RefAttributes<any>>;
35
39
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/color-picker",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "Jira Color Picker Component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,7 +32,7 @@
32
32
  "@atlaskit/analytics-next": "^10.1.0",
33
33
  "@atlaskit/icon": "^22.18.0",
34
34
  "@atlaskit/platform-feature-flags": "0.3.0",
35
- "@atlaskit/select": "^17.18.0",
35
+ "@atlaskit/select": "^17.19.0",
36
36
  "@atlaskit/theme": "^13.0.0",
37
37
  "@atlaskit/tokens": "^1.60.0",
38
38
  "@atlaskit/tooltip": "^18.7.0",
@@ -75,9 +75,6 @@
75
75
  }
76
76
  },
77
77
  "platform-feature-flags": {
78
- "platform_color_palette_menu_timeline_bar_a11y": {
79
- "type": "boolean"
80
- },
81
78
  "platform_color_palette-expose-event": {
82
79
  "type": "boolean"
83
80
  },