@atlaskit/color-picker 3.2.26 → 3.3.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.
- package/CHANGELOG.md +22 -0
- package/afm-jira/tsconfig.json +3 -0
- package/dist/cjs/components/ColorCard.js +21 -24
- package/dist/cjs/components/ColorPaletteMenu.js +34 -20
- package/dist/cjs/components/ColorPicker.js +4 -4
- package/dist/cjs/components/Trigger.js +2 -1
- package/dist/cjs/components/components.js +2 -0
- package/dist/cjs/constants.js +9 -4
- package/dist/cjs/index.js +1 -1
- package/dist/es2019/components/ColorCard.js +20 -27
- package/dist/es2019/components/ColorPaletteMenu.js +31 -16
- package/dist/es2019/components/ColorPicker.js +3 -3
- package/dist/es2019/components/Trigger.js +2 -1
- package/dist/es2019/components/components.js +2 -0
- package/dist/es2019/constants.js +8 -3
- package/dist/esm/components/ColorCard.js +21 -24
- package/dist/esm/components/ColorPaletteMenu.js +34 -20
- package/dist/esm/components/ColorPicker.js +4 -4
- package/dist/esm/components/Trigger.js +2 -1
- package/dist/esm/components/components.js +2 -0
- package/dist/esm/constants.js +8 -3
- package/dist/types/components/ColorCard.d.ts +2 -0
- package/dist/types/components/ColorPaletteMenu.d.ts +4 -2
- package/dist/types/constants.d.ts +7 -2
- package/dist/types/types.d.ts +2 -0
- package/dist/types-ts4.5/components/ColorCard.d.ts +2 -0
- package/dist/types-ts4.5/components/ColorPaletteMenu.d.ts +4 -2
- package/dist/types-ts4.5/constants.d.ts +7 -2
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/package.json +8 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/color-picker
|
|
2
2
|
|
|
3
|
+
## 3.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#134622](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134622)
|
|
8
|
+
[`66b5d35764e86`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/66b5d35764e86) -
|
|
9
|
+
Added feature flag for hiding trigger focus styles on expand
|
|
10
|
+
(https://product-fabric.atlassian.net/browse/DSP-20821)
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 3.2.27
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#137781](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/137781)
|
|
21
|
+
[`2780cda402d6b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2780cda402d6b) -
|
|
22
|
+
[ux] Improve focus for color picker
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 3.2.26
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/afm-jira/tsconfig.json
CHANGED
|
@@ -16,7 +16,7 @@ var _react2 = require("@emotion/react");
|
|
|
16
16
|
var _colors = require("@atlaskit/theme/colors");
|
|
17
17
|
var _useCallbackRef = require("use-callback-ref");
|
|
18
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
20
|
/**
|
|
21
21
|
* @jsxRuntime classic
|
|
22
22
|
* @jsx jsx
|
|
@@ -25,7 +25,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
25
25
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
26
26
|
|
|
27
27
|
var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRef) {
|
|
28
|
-
var
|
|
28
|
+
var type = props.type,
|
|
29
|
+
initialFocusRef = props.initialFocusRef,
|
|
29
30
|
value = props.value,
|
|
30
31
|
label = props.label,
|
|
31
32
|
selected = props.selected,
|
|
@@ -37,6 +38,8 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
|
|
|
37
38
|
onKeyDown = props.onKeyDown;
|
|
38
39
|
var ref = (0, _react.useRef)(null);
|
|
39
40
|
var isInitialFocus = (0, _react.useRef)(true);
|
|
41
|
+
var isColorPaletteMenu = type === _constants.COLOR_PALETTE_MENU;
|
|
42
|
+
var isTabbingIgnored = (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') ? isColorPaletteMenu : false;
|
|
40
43
|
var handleMouseDown = (0, _react.useCallback)(function (event) {
|
|
41
44
|
event.preventDefault();
|
|
42
45
|
}, []);
|
|
@@ -46,36 +49,30 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
|
|
|
46
49
|
onClick(value);
|
|
47
50
|
}
|
|
48
51
|
}, [onClick, value]);
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
if ((isTabbing === undefined || isTabbing) && onClick && (key === _constants.KEY_ENTER || key === _constants.KEY_SPACE)) {
|
|
52
|
+
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
53
|
+
if ((isTabbingIgnored || isTabbing === undefined || isTabbing) && onClick && (event.key === _constants.KEY_ENTER || event.key === _constants.KEY_SPACE)) {
|
|
52
54
|
event.preventDefault();
|
|
53
55
|
if (isTabbing) {
|
|
54
56
|
event.stopPropagation();
|
|
55
57
|
}
|
|
56
58
|
onClick(value);
|
|
57
59
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
event.preventDefault();
|
|
63
|
-
if (isTabbing) {
|
|
60
|
+
if ((0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y')) {
|
|
61
|
+
if (isColorPaletteMenu) {
|
|
62
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
|
|
63
|
+
} else if (event.key === _constants.KEY_TAB) {
|
|
64
64
|
event.stopPropagation();
|
|
65
|
+
event.preventDefault();
|
|
65
66
|
}
|
|
66
|
-
onClick === null || onClick === void 0 || onClick(value);
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
}, [isTabbing, onClick, onKeyDown, value]);
|
|
70
|
-
|
|
71
|
-
// TODO: Remove this useEffect when the feature flag 'platform_color_palette_menu_timeline_bar_a11y' is cleaned up
|
|
68
|
+
}, [isTabbing, isTabbingIgnored, isColorPaletteMenu, onClick, onKeyDown, value]);
|
|
72
69
|
(0, _react.useEffect)(function () {
|
|
73
70
|
if (!(0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y')) {
|
|
74
71
|
var refCurrent = ref.current;
|
|
75
|
-
var handleTabKey = function handleTabKey(
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
var handleTabKey = function handleTabKey(event) {
|
|
73
|
+
if (event.key === _constants.KEY_TAB) {
|
|
74
|
+
event.stopPropagation();
|
|
75
|
+
event.preventDefault();
|
|
79
76
|
}
|
|
80
77
|
};
|
|
81
78
|
refCurrent === null || refCurrent === void 0 || refCurrent.addEventListener('keydown', handleTabKey);
|
|
@@ -87,7 +84,7 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
|
|
|
87
84
|
(0, _react.useImperativeHandle)(componentRef, function () {
|
|
88
85
|
return {
|
|
89
86
|
focus: function focus() {
|
|
90
|
-
if (
|
|
87
|
+
if (isTabbingIgnored) {
|
|
91
88
|
if (isInitialFocus.current) {
|
|
92
89
|
var _ref$current;
|
|
93
90
|
!initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
|
|
@@ -99,7 +96,7 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
|
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
98
|
};
|
|
102
|
-
}, [initialFocusRef]);
|
|
99
|
+
}, [isTabbingIgnored, initialFocusRef]);
|
|
103
100
|
return (0, _react2.jsx)(_tooltip.default, {
|
|
104
101
|
content: label
|
|
105
102
|
}, function (tooltipProps) {
|
|
@@ -110,10 +107,10 @@ var ColorCard = /*#__PURE__*/(0, _react.forwardRef)(function (props, componentRe
|
|
|
110
107
|
tabIndex: (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') ? selected ? 0 : -1 : 0,
|
|
111
108
|
"aria-checked": selected,
|
|
112
109
|
"aria-label": label,
|
|
113
|
-
css: [sharedColorContainerStyles, (isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && !isTabbing && colorCardOptionFocusedStyles],
|
|
110
|
+
css: [sharedColorContainerStyles, (isTabbingIgnored || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isTabbingIgnored || !isTabbing) && colorCardOptionFocusedStyles],
|
|
114
111
|
onClick: handleClick,
|
|
115
112
|
onMouseDown: handleMouseDown,
|
|
116
|
-
onKeyDown:
|
|
113
|
+
onKeyDown: handleKeyDown
|
|
117
114
|
}), (0, _react2.jsx)("div", {
|
|
118
115
|
css: colorCardWrapperStyles
|
|
119
116
|
}, (0, _react2.jsx)("div", {
|
|
@@ -14,6 +14,7 @@ var _ColorCard = _interopRequireDefault(require("./ColorCard"));
|
|
|
14
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
15
|
var _utils = require("../utils");
|
|
16
16
|
var _react2 = require("@emotion/react");
|
|
17
|
+
var _constants = require("../constants");
|
|
17
18
|
var _colors = require("@atlaskit/theme/colors");
|
|
18
19
|
/**
|
|
19
20
|
* @jsxRuntime classic
|
|
@@ -23,7 +24,9 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
23
24
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
24
25
|
|
|
25
26
|
var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAnalytics(_ref) {
|
|
26
|
-
var
|
|
27
|
+
var _ref$isFocusLockEnabl = _ref.isFocusLockEnabled,
|
|
28
|
+
isFocusLockEnabled = _ref$isFocusLockEnabl === void 0 ? true : _ref$isFocusLockEnabl,
|
|
29
|
+
createAnalyticsEvent = _ref.createAnalyticsEvent,
|
|
27
30
|
onChange = _ref.onChange,
|
|
28
31
|
palette = _ref.palette,
|
|
29
32
|
selectedColor = _ref.selectedColor,
|
|
@@ -35,6 +38,18 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
35
38
|
_ref$mode = _ref.mode,
|
|
36
39
|
mode = _ref$mode === void 0 ? _types.Mode.Standard : _ref$mode,
|
|
37
40
|
initialFocusRef = _ref.initialFocusRef;
|
|
41
|
+
var _getOptions = (0, _utils.getOptions)(palette, selectedColor),
|
|
42
|
+
options = _getOptions.options,
|
|
43
|
+
selectedValue = _getOptions.value;
|
|
44
|
+
var fullLabel = "".concat(label, ", ").concat(selectedValue.label, " selected");
|
|
45
|
+
var selectedColorIndex = selectedValue.value ? options.findIndex(function (_ref2) {
|
|
46
|
+
var value = _ref2.value;
|
|
47
|
+
return value === selectedValue.value;
|
|
48
|
+
}) : 0;
|
|
49
|
+
var _useState = (0, _react.useState)(selectedColorIndex),
|
|
50
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
51
|
+
focusedIndex = _useState2[0],
|
|
52
|
+
setFocusedIndex = _useState2[1];
|
|
38
53
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
39
54
|
var changeAnalyticsCaller = function changeAnalyticsCaller() {
|
|
40
55
|
if (createAnalyticsEvent) {
|
|
@@ -44,7 +59,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
44
59
|
attributes: {
|
|
45
60
|
componentName: 'color-picker',
|
|
46
61
|
packageName: "@atlaskit/color-picker",
|
|
47
|
-
packageVersion: "3.
|
|
62
|
+
packageVersion: "3.3.0"
|
|
48
63
|
}
|
|
49
64
|
})(createAnalyticsEvent);
|
|
50
65
|
}
|
|
@@ -56,17 +71,6 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
56
71
|
var handleChange = function handleChange(value) {
|
|
57
72
|
onChange(value, changeAnalyticsCaller());
|
|
58
73
|
};
|
|
59
|
-
var _getOptions = (0, _utils.getOptions)(palette, selectedColor),
|
|
60
|
-
options = _getOptions.options,
|
|
61
|
-
selectedValue = _getOptions.value;
|
|
62
|
-
var fullLabel = "".concat(label, ", ").concat(selectedValue.label, " selected");
|
|
63
|
-
var _useState = (0, _react.useState)(selectedValue.value ? options.findIndex(function (_ref2) {
|
|
64
|
-
var value = _ref2.value;
|
|
65
|
-
return value === selectedValue.value;
|
|
66
|
-
}) : 0),
|
|
67
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
68
|
-
focusedIndex = _useState2[0],
|
|
69
|
-
setFocusedIndex = _useState2[1];
|
|
70
74
|
(0, _react.useEffect)(function () {
|
|
71
75
|
var _colorCardRefs$focuse;
|
|
72
76
|
(_colorCardRefs$focuse = colorCardRefs[focusedIndex]) === null || _colorCardRefs$focuse === void 0 || _colorCardRefs$focuse.focus();
|
|
@@ -74,22 +78,31 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
74
78
|
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
75
79
|
var numItems = options.length;
|
|
76
80
|
switch (event.key) {
|
|
77
|
-
case
|
|
78
|
-
case
|
|
81
|
+
case _constants.KEY_ARROW_DOWN:
|
|
82
|
+
case _constants.KEY_ARROW_RIGHT:
|
|
79
83
|
setFocusedIndex(function (prevIndex) {
|
|
80
84
|
return (prevIndex + 1) % numItems;
|
|
81
85
|
});
|
|
82
86
|
break;
|
|
83
|
-
case
|
|
84
|
-
case
|
|
87
|
+
case _constants.KEY_ARROW_UP:
|
|
88
|
+
case _constants.KEY_ARROW_LEFT:
|
|
85
89
|
setFocusedIndex(function (prevIndex) {
|
|
86
90
|
return (prevIndex - 1 + numItems) % numItems;
|
|
87
91
|
});
|
|
88
92
|
break;
|
|
93
|
+
case _constants.KEY_TAB:
|
|
94
|
+
{
|
|
95
|
+
if (isFocusLockEnabled) {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
event.stopPropagation();
|
|
98
|
+
setFocusedIndex(selectedColorIndex);
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
89
102
|
default:
|
|
90
103
|
break;
|
|
91
104
|
}
|
|
92
|
-
}, [setFocusedIndex, options]);
|
|
105
|
+
}, [isFocusLockEnabled, selectedColorIndex, setFocusedIndex, options]);
|
|
93
106
|
return (0, _react2.jsx)("div", {
|
|
94
107
|
"aria-label": fullLabel,
|
|
95
108
|
role: (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup'
|
|
@@ -111,6 +124,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
111
124
|
css: colorCardWrapperStyles,
|
|
112
125
|
key: value
|
|
113
126
|
}, (0, _react2.jsx)(_ColorCard.default, (0, _extends2.default)({
|
|
127
|
+
type: _constants.COLOR_PALETTE_MENU,
|
|
114
128
|
label: label,
|
|
115
129
|
value: value,
|
|
116
130
|
checkMarkColor: checkMarkColor,
|
|
@@ -119,7 +133,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
119
133
|
onClick: handleChange
|
|
120
134
|
}, (0, _platformFeatureFlags.fg)('platform_color_palette_menu_timeline_bar_a11y') && {
|
|
121
135
|
ref: function ref(_ref4) {
|
|
122
|
-
|
|
136
|
+
colorCardRefs[index] = _ref4;
|
|
123
137
|
},
|
|
124
138
|
initialFocusRef: value === selectedValue.value ? initialFocusRef : undefined,
|
|
125
139
|
onKeyDown: handleKeyDown
|
|
@@ -129,7 +143,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
129
143
|
var _default = exports.default = (0, _analyticsNext.withAnalyticsContext)({
|
|
130
144
|
componentName: 'color-picker',
|
|
131
145
|
packageName: "@atlaskit/color-picker",
|
|
132
|
-
packageVersion: "3.
|
|
146
|
+
packageVersion: "3.3.0"
|
|
133
147
|
})((0, _analyticsNext.withAnalyticsEvents)()(ColorPaletteMenuWithoutAnalytics));
|
|
134
148
|
var colorCardWrapperStyles = (0, _react2.css)({
|
|
135
149
|
display: 'flex',
|
|
@@ -25,8 +25,8 @@ var _react2 = require("@emotion/react");
|
|
|
25
25
|
var _reactIntlNext = require("react-intl-next");
|
|
26
26
|
var _messages = _interopRequireDefault(require("../messages"));
|
|
27
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
28
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
29
|
-
function _createSuper(
|
|
28
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
|
|
30
30
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
|
|
31
31
|
* @jsxRuntime classic
|
|
32
32
|
* @jsx jsx
|
|
@@ -42,7 +42,7 @@ var defaultPopperProps = {
|
|
|
42
42
|
placement: 'bottom-start'
|
|
43
43
|
};
|
|
44
44
|
var packageName = "@atlaskit/color-picker";
|
|
45
|
-
var packageVersion = "3.
|
|
45
|
+
var packageVersion = "3.3.0";
|
|
46
46
|
var ColorPickerWithoutAnalyticsBase = /*#__PURE__*/function (_React$Component) {
|
|
47
47
|
(0, _inherits2.default)(ColorPickerWithoutAnalyticsBase, _React$Component);
|
|
48
48
|
var _super = _createSuper(ColorPickerWithoutAnalyticsBase);
|
|
@@ -88,7 +88,7 @@ var ColorPickerWithoutAnalyticsBase = /*#__PURE__*/function (_React$Component) {
|
|
|
88
88
|
_this.setState({
|
|
89
89
|
isTabbing: false
|
|
90
90
|
});
|
|
91
|
-
} else if (key ===
|
|
91
|
+
} else if (key === _constants.KEY_ESCAPE) {
|
|
92
92
|
e.stopPropagation();
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _react2 = require("@emotion/react");
|
|
11
12
|
var _colors = require("@atlaskit/theme/colors");
|
|
12
13
|
/**
|
|
@@ -38,7 +39,7 @@ var ColorCard = function ColorCard(_ref) {
|
|
|
38
39
|
return (0, _react2.jsx)(_tooltip.default, {
|
|
39
40
|
content: label
|
|
40
41
|
}, (0, _react2.jsx)("button", {
|
|
41
|
-
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
42
|
+
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && !(0, _platformFeatureFlags.fg)('platform-design-system-dsp-20821-color-pickr-focus') && colorCardButtonFocusedStyles],
|
|
42
43
|
disabled: isDisabled,
|
|
43
44
|
onClick: handleClick,
|
|
44
45
|
onMouseDown: handleMouseDown,
|
|
@@ -10,6 +10,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
10
10
|
var _ColorCard = _interopRequireDefault(require("./ColorCard"));
|
|
11
11
|
var _utils = require("../utils");
|
|
12
12
|
var _react = require("@emotion/react");
|
|
13
|
+
var _constants = require("../constants");
|
|
13
14
|
/**
|
|
14
15
|
* @jsxRuntime classic
|
|
15
16
|
* @jsx jsx
|
|
@@ -45,6 +46,7 @@ var Option = exports.Option = function Option(props) {
|
|
|
45
46
|
return (0, _react.jsx)("div", (0, _extends2.default)({
|
|
46
47
|
css: colorCardWrapperStyles
|
|
47
48
|
}, innerProps), (0, _react.jsx)(_ColorCard.default, {
|
|
49
|
+
type: _constants.COLOR_PICKER,
|
|
48
50
|
label: label,
|
|
49
51
|
value: value,
|
|
50
52
|
checkMarkColor: checkMarkColor,
|
package/dist/cjs/constants.js
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.KEY_TAB = exports.KEY_SPACE = exports.KEY_ENTER = exports.KEY_ARROW_UP = exports.KEY_ARROW_DOWN = exports.COLOR_CARD_SIZE = void 0;
|
|
6
|
+
exports.KEY_TAB = exports.KEY_SPACE = exports.KEY_ESCAPE = exports.KEY_ENTER = exports.KEY_ARROW_UP = exports.KEY_ARROW_RIGHT = exports.KEY_ARROW_LEFT = exports.KEY_ARROW_DOWN = exports.COLOR_PICKER = exports.COLOR_PALETTE_MENU = exports.COLOR_CARD_SIZE = void 0;
|
|
7
|
+
var COLOR_PICKER = exports.COLOR_PICKER = 'COLOR_PICKER';
|
|
8
|
+
var COLOR_PALETTE_MENU = exports.COLOR_PALETTE_MENU = 'COLOR_PALETTE_MENU';
|
|
7
9
|
var COLOR_CARD_SIZE = exports.COLOR_CARD_SIZE = 32;
|
|
8
10
|
var KEY_SPACE = exports.KEY_SPACE = ' ';
|
|
9
11
|
var KEY_ENTER = exports.KEY_ENTER = 'Enter';
|
|
10
|
-
var KEY_ARROW_UP = exports.KEY_ARROW_UP = '
|
|
11
|
-
var KEY_ARROW_DOWN = exports.KEY_ARROW_DOWN = '
|
|
12
|
-
var
|
|
12
|
+
var KEY_ARROW_UP = exports.KEY_ARROW_UP = 'ArrowUp';
|
|
13
|
+
var KEY_ARROW_DOWN = exports.KEY_ARROW_DOWN = 'ArrowDown';
|
|
14
|
+
var KEY_ARROW_LEFT = exports.KEY_ARROW_LEFT = 'ArrowLeft';
|
|
15
|
+
var KEY_ARROW_RIGHT = exports.KEY_ARROW_RIGHT = 'ArrowRight';
|
|
16
|
+
var KEY_TAB = exports.KEY_TAB = 'Tab';
|
|
17
|
+
var KEY_ESCAPE = exports.KEY_ESCAPE = 'Escape';
|
package/dist/cjs/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var _ColorPicker = _interopRequireWildcard(require("./components/ColorPicker"));
|
|
|
27
27
|
var _types = require("./types");
|
|
28
28
|
var _ColorPaletteMenu = _interopRequireWildcard(require("./components/ColorPaletteMenu"));
|
|
29
29
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
30
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
30
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
31
31
|
var Compact = exports.Compact = _types.Mode.Compact,
|
|
32
32
|
Standard = exports.Standard = _types.Mode.Standard;
|
|
33
33
|
var _default = exports.default = _ColorPicker.default;
|
|
@@ -7,13 +7,14 @@ import React, { useCallback, useEffect, useRef, useImperativeHandle, forwardRef
|
|
|
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';
|
|
10
|
-
import { KEY_ENTER, KEY_SPACE } from '../constants';
|
|
10
|
+
import { COLOR_PALETTE_MENU, KEY_ENTER, KEY_SPACE, KEY_TAB } from '../constants';
|
|
11
11
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
12
12
|
import { css, jsx } from '@emotion/react';
|
|
13
13
|
import { N0, DN600A, B75 } from '@atlaskit/theme/colors';
|
|
14
14
|
import { mergeRefs } from 'use-callback-ref';
|
|
15
15
|
const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
|
|
16
16
|
const {
|
|
17
|
+
type,
|
|
17
18
|
initialFocusRef,
|
|
18
19
|
value,
|
|
19
20
|
label,
|
|
@@ -26,6 +27,8 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
|
|
|
26
27
|
} = props;
|
|
27
28
|
const ref = useRef(null);
|
|
28
29
|
const isInitialFocus = useRef(true);
|
|
30
|
+
const isColorPaletteMenu = type === COLOR_PALETTE_MENU;
|
|
31
|
+
const isTabbingIgnored = fg('platform_color_palette_menu_timeline_bar_a11y') ? isColorPaletteMenu : false;
|
|
29
32
|
const handleMouseDown = useCallback(event => {
|
|
30
33
|
event.preventDefault();
|
|
31
34
|
}, []);
|
|
@@ -35,40 +38,30 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
|
|
|
35
38
|
onClick(value);
|
|
36
39
|
}
|
|
37
40
|
}, [onClick, value]);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
key
|
|
41
|
-
} = event;
|
|
42
|
-
if ((isTabbing === undefined || isTabbing) && onClick && (key === KEY_ENTER || key === KEY_SPACE)) {
|
|
41
|
+
const handleKeyDown = useCallback(event => {
|
|
42
|
+
if ((isTabbingIgnored || isTabbing === undefined || isTabbing) && onClick && (event.key === KEY_ENTER || event.key === KEY_SPACE)) {
|
|
43
43
|
event.preventDefault();
|
|
44
44
|
if (isTabbing) {
|
|
45
45
|
event.stopPropagation();
|
|
46
46
|
}
|
|
47
47
|
onClick(value);
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
key
|
|
53
|
-
} = event;
|
|
54
|
-
if ((isTabbing === undefined || isTabbing) && (key === KEY_ENTER || key === KEY_SPACE)) {
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
if (isTabbing) {
|
|
49
|
+
if (fg('platform_color_palette_menu_timeline_bar_a11y')) {
|
|
50
|
+
if (isColorPaletteMenu) {
|
|
51
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
52
|
+
} else if (event.key === KEY_TAB) {
|
|
57
53
|
event.stopPropagation();
|
|
54
|
+
event.preventDefault();
|
|
58
55
|
}
|
|
59
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(value);
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
}, [isTabbing, onClick, onKeyDown, value]);
|
|
63
|
-
|
|
64
|
-
// TODO: Remove this useEffect when the feature flag 'platform_color_palette_menu_timeline_bar_a11y' is cleaned up
|
|
57
|
+
}, [isTabbing, isTabbingIgnored, isColorPaletteMenu, onClick, onKeyDown, value]);
|
|
65
58
|
useEffect(() => {
|
|
66
59
|
if (!fg('platform_color_palette_menu_timeline_bar_a11y')) {
|
|
67
60
|
const refCurrent = ref.current;
|
|
68
|
-
const handleTabKey =
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
const handleTabKey = event => {
|
|
62
|
+
if (event.key === KEY_TAB) {
|
|
63
|
+
event.stopPropagation();
|
|
64
|
+
event.preventDefault();
|
|
72
65
|
}
|
|
73
66
|
};
|
|
74
67
|
refCurrent === null || refCurrent === void 0 ? void 0 : refCurrent.addEventListener('keydown', handleTabKey);
|
|
@@ -79,7 +72,7 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
|
|
|
79
72
|
}, []);
|
|
80
73
|
useImperativeHandle(componentRef, () => ({
|
|
81
74
|
focus: () => {
|
|
82
|
-
if (
|
|
75
|
+
if (isTabbingIgnored) {
|
|
83
76
|
if (isInitialFocus.current) {
|
|
84
77
|
var _ref$current;
|
|
85
78
|
!initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
|
|
@@ -90,7 +83,7 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
|
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
|
-
}), [initialFocusRef]);
|
|
86
|
+
}), [isTabbingIgnored, initialFocusRef]);
|
|
94
87
|
return jsx(Tooltip, {
|
|
95
88
|
content: label
|
|
96
89
|
}, tooltipProps => {
|
|
@@ -101,10 +94,10 @@ const ColorCard = /*#__PURE__*/forwardRef((props, componentRef) => {
|
|
|
101
94
|
tabIndex: fg('platform_color_palette_menu_timeline_bar_a11y') ? selected ? 0 : -1 : 0,
|
|
102
95
|
"aria-checked": selected,
|
|
103
96
|
"aria-label": label,
|
|
104
|
-
css: [sharedColorContainerStyles, (isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && !isTabbing && colorCardOptionFocusedStyles],
|
|
97
|
+
css: [sharedColorContainerStyles, (isTabbingIgnored || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isTabbingIgnored || !isTabbing) && colorCardOptionFocusedStyles],
|
|
105
98
|
onClick: handleClick,
|
|
106
99
|
onMouseDown: handleMouseDown,
|
|
107
|
-
onKeyDown:
|
|
100
|
+
onKeyDown: handleKeyDown
|
|
108
101
|
}), jsx("div", {
|
|
109
102
|
css: colorCardWrapperStyles
|
|
110
103
|
}, jsx("div", {
|
|
@@ -11,8 +11,10 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
11
11
|
import { getOptions, getWidth } from '../utils';
|
|
12
12
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
13
|
import { css, jsx } from '@emotion/react';
|
|
14
|
+
import { COLOR_PALETTE_MENU, KEY_ARROW_UP, KEY_ARROW_DOWN, KEY_ARROW_LEFT, KEY_ARROW_RIGHT, KEY_TAB } from '../constants';
|
|
14
15
|
import { N0, N40 } from '@atlaskit/theme/colors';
|
|
15
16
|
export const ColorPaletteMenuWithoutAnalytics = ({
|
|
17
|
+
isFocusLockEnabled = true,
|
|
16
18
|
createAnalyticsEvent,
|
|
17
19
|
onChange,
|
|
18
20
|
palette,
|
|
@@ -23,6 +25,15 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
23
25
|
mode = Mode.Standard,
|
|
24
26
|
initialFocusRef
|
|
25
27
|
}) => {
|
|
28
|
+
const {
|
|
29
|
+
options,
|
|
30
|
+
value: selectedValue
|
|
31
|
+
} = getOptions(palette, selectedColor);
|
|
32
|
+
const fullLabel = `${label}, ${selectedValue.label} selected`;
|
|
33
|
+
const selectedColorIndex = selectedValue.value ? options.findIndex(({
|
|
34
|
+
value
|
|
35
|
+
}) => value === selectedValue.value) : 0;
|
|
36
|
+
const [focusedIndex, setFocusedIndex] = useState(selectedColorIndex);
|
|
26
37
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
27
38
|
const changeAnalyticsCaller = () => {
|
|
28
39
|
if (createAnalyticsEvent) {
|
|
@@ -32,7 +43,7 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
32
43
|
attributes: {
|
|
33
44
|
componentName: 'color-picker',
|
|
34
45
|
packageName: "@atlaskit/color-picker",
|
|
35
|
-
packageVersion: "3.
|
|
46
|
+
packageVersion: "3.3.0"
|
|
36
47
|
}
|
|
37
48
|
})(createAnalyticsEvent);
|
|
38
49
|
}
|
|
@@ -42,14 +53,6 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
42
53
|
const handleChange = value => {
|
|
43
54
|
onChange(value, changeAnalyticsCaller());
|
|
44
55
|
};
|
|
45
|
-
const {
|
|
46
|
-
options,
|
|
47
|
-
value: selectedValue
|
|
48
|
-
} = getOptions(palette, selectedColor);
|
|
49
|
-
const fullLabel = `${label}, ${selectedValue.label} selected`;
|
|
50
|
-
const [focusedIndex, setFocusedIndex] = useState(selectedValue.value ? options.findIndex(({
|
|
51
|
-
value
|
|
52
|
-
}) => value === selectedValue.value) : 0);
|
|
53
56
|
useEffect(() => {
|
|
54
57
|
var _colorCardRefs$focuse;
|
|
55
58
|
(_colorCardRefs$focuse = colorCardRefs[focusedIndex]) === null || _colorCardRefs$focuse === void 0 ? void 0 : _colorCardRefs$focuse.focus();
|
|
@@ -57,18 +60,27 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
57
60
|
const handleKeyDown = useCallback(event => {
|
|
58
61
|
const numItems = options.length;
|
|
59
62
|
switch (event.key) {
|
|
60
|
-
case
|
|
61
|
-
case
|
|
63
|
+
case KEY_ARROW_DOWN:
|
|
64
|
+
case KEY_ARROW_RIGHT:
|
|
62
65
|
setFocusedIndex(prevIndex => (prevIndex + 1) % numItems);
|
|
63
66
|
break;
|
|
64
|
-
case
|
|
65
|
-
case
|
|
67
|
+
case KEY_ARROW_UP:
|
|
68
|
+
case KEY_ARROW_LEFT:
|
|
66
69
|
setFocusedIndex(prevIndex => (prevIndex - 1 + numItems) % numItems);
|
|
67
70
|
break;
|
|
71
|
+
case KEY_TAB:
|
|
72
|
+
{
|
|
73
|
+
if (isFocusLockEnabled) {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
event.stopPropagation();
|
|
76
|
+
setFocusedIndex(selectedColorIndex);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
68
80
|
default:
|
|
69
81
|
break;
|
|
70
82
|
}
|
|
71
|
-
}, [setFocusedIndex, options]);
|
|
83
|
+
}, [isFocusLockEnabled, selectedColorIndex, setFocusedIndex, options]);
|
|
72
84
|
return jsx("div", {
|
|
73
85
|
"aria-label": fullLabel,
|
|
74
86
|
role: fg('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup'
|
|
@@ -90,6 +102,7 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
90
102
|
css: colorCardWrapperStyles,
|
|
91
103
|
key: value
|
|
92
104
|
}, jsx(ColorCard, _extends({
|
|
105
|
+
type: COLOR_PALETTE_MENU,
|
|
93
106
|
label: label,
|
|
94
107
|
value: value,
|
|
95
108
|
checkMarkColor: checkMarkColor,
|
|
@@ -97,7 +110,9 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
97
110
|
selected: value === selectedValue.value,
|
|
98
111
|
onClick: handleChange
|
|
99
112
|
}, fg('platform_color_palette_menu_timeline_bar_a11y') && {
|
|
100
|
-
ref: ref =>
|
|
113
|
+
ref: ref => {
|
|
114
|
+
colorCardRefs[index] = ref;
|
|
115
|
+
},
|
|
101
116
|
initialFocusRef: value === selectedValue.value ? initialFocusRef : undefined,
|
|
102
117
|
onKeyDown: handleKeyDown
|
|
103
118
|
}))))));
|
|
@@ -105,7 +120,7 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
105
120
|
export default withAnalyticsContext({
|
|
106
121
|
componentName: 'color-picker',
|
|
107
122
|
packageName: "@atlaskit/color-picker",
|
|
108
|
-
packageVersion: "3.
|
|
123
|
+
packageVersion: "3.3.0"
|
|
109
124
|
})(withAnalyticsEvents()(ColorPaletteMenuWithoutAnalytics));
|
|
110
125
|
const colorCardWrapperStyles = css({
|
|
111
126
|
display: 'flex',
|
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import { PopupSelect } from '@atlaskit/select';
|
|
9
9
|
import Trigger from './Trigger';
|
|
10
10
|
import * as components from './components';
|
|
11
|
-
import { KEY_ARROW_DOWN, KEY_ARROW_UP, KEY_TAB } from '../constants';
|
|
11
|
+
import { KEY_ARROW_DOWN, KEY_ARROW_UP, KEY_TAB, KEY_ESCAPE } from '../constants';
|
|
12
12
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
13
13
|
import { getOptions } from '../utils';
|
|
14
14
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
@@ -26,7 +26,7 @@ const defaultPopperProps = {
|
|
|
26
26
|
placement: 'bottom-start'
|
|
27
27
|
};
|
|
28
28
|
const packageName = "@atlaskit/color-picker";
|
|
29
|
-
const packageVersion = "3.
|
|
29
|
+
const packageVersion = "3.3.0";
|
|
30
30
|
class ColorPickerWithoutAnalyticsBase extends React.Component {
|
|
31
31
|
constructor(...args) {
|
|
32
32
|
super(...args);
|
|
@@ -67,7 +67,7 @@ class ColorPickerWithoutAnalyticsBase extends React.Component {
|
|
|
67
67
|
this.setState({
|
|
68
68
|
isTabbing: false
|
|
69
69
|
});
|
|
70
|
-
} else if (key ===
|
|
70
|
+
} else if (key === KEY_ESCAPE) {
|
|
71
71
|
e.stopPropagation();
|
|
72
72
|
}
|
|
73
73
|
});
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
6
|
import Tooltip from '@atlaskit/tooltip';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
9
|
import { css, jsx } from '@emotion/react';
|
|
9
10
|
import { B100, DN600A, N0 } from '@atlaskit/theme/colors';
|
|
@@ -29,7 +30,7 @@ const ColorCard = ({
|
|
|
29
30
|
return jsx(Tooltip, {
|
|
30
31
|
content: label
|
|
31
32
|
}, jsx("button", {
|
|
32
|
-
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
33
|
+
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && !fg('platform-design-system-dsp-20821-color-pickr-focus') && colorCardButtonFocusedStyles],
|
|
33
34
|
disabled: isDisabled,
|
|
34
35
|
onClick: handleClick,
|
|
35
36
|
onMouseDown: handleMouseDown,
|
|
@@ -9,6 +9,7 @@ import ColorCard from './ColorCard';
|
|
|
9
9
|
import { getWidth } from '../utils';
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { css, jsx } from '@emotion/react';
|
|
12
|
+
import { COLOR_PICKER } from '../constants';
|
|
12
13
|
export const MenuList = props => {
|
|
13
14
|
const {
|
|
14
15
|
selectProps: {
|
|
@@ -45,6 +46,7 @@ export const Option = props => {
|
|
|
45
46
|
return jsx("div", _extends({
|
|
46
47
|
css: colorCardWrapperStyles
|
|
47
48
|
}, innerProps), jsx(ColorCard, {
|
|
49
|
+
type: COLOR_PICKER,
|
|
48
50
|
label: label,
|
|
49
51
|
value: value,
|
|
50
52
|
checkMarkColor: checkMarkColor,
|
package/dist/es2019/constants.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
export const COLOR_PICKER = 'COLOR_PICKER';
|
|
2
|
+
export const COLOR_PALETTE_MENU = 'COLOR_PALETTE_MENU';
|
|
1
3
|
export const COLOR_CARD_SIZE = 32;
|
|
2
4
|
export const KEY_SPACE = ' ';
|
|
3
5
|
export const KEY_ENTER = 'Enter';
|
|
4
|
-
export const KEY_ARROW_UP = '
|
|
5
|
-
export const KEY_ARROW_DOWN = '
|
|
6
|
-
export const
|
|
6
|
+
export const KEY_ARROW_UP = 'ArrowUp';
|
|
7
|
+
export const KEY_ARROW_DOWN = 'ArrowDown';
|
|
8
|
+
export const KEY_ARROW_LEFT = 'ArrowLeft';
|
|
9
|
+
export const KEY_ARROW_RIGHT = 'ArrowRight';
|
|
10
|
+
export const KEY_TAB = 'Tab';
|
|
11
|
+
export const KEY_ESCAPE = 'Escape';
|
|
@@ -7,13 +7,14 @@ import React, { useCallback, useEffect, useRef, useImperativeHandle, forwardRef
|
|
|
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';
|
|
10
|
-
import { KEY_ENTER, KEY_SPACE } from '../constants';
|
|
10
|
+
import { COLOR_PALETTE_MENU, KEY_ENTER, KEY_SPACE, KEY_TAB } from '../constants';
|
|
11
11
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
12
12
|
import { css, jsx } from '@emotion/react';
|
|
13
13
|
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
|
-
var
|
|
16
|
+
var type = props.type,
|
|
17
|
+
initialFocusRef = props.initialFocusRef,
|
|
17
18
|
value = props.value,
|
|
18
19
|
label = props.label,
|
|
19
20
|
selected = props.selected,
|
|
@@ -25,6 +26,8 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
|
|
|
25
26
|
onKeyDown = props.onKeyDown;
|
|
26
27
|
var ref = useRef(null);
|
|
27
28
|
var isInitialFocus = useRef(true);
|
|
29
|
+
var isColorPaletteMenu = type === COLOR_PALETTE_MENU;
|
|
30
|
+
var isTabbingIgnored = fg('platform_color_palette_menu_timeline_bar_a11y') ? isColorPaletteMenu : false;
|
|
28
31
|
var handleMouseDown = useCallback(function (event) {
|
|
29
32
|
event.preventDefault();
|
|
30
33
|
}, []);
|
|
@@ -34,36 +37,30 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
|
|
|
34
37
|
onClick(value);
|
|
35
38
|
}
|
|
36
39
|
}, [onClick, value]);
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
if ((isTabbing === undefined || isTabbing) && onClick && (key === KEY_ENTER || key === KEY_SPACE)) {
|
|
40
|
+
var handleKeyDown = useCallback(function (event) {
|
|
41
|
+
if ((isTabbingIgnored || isTabbing === undefined || isTabbing) && onClick && (event.key === KEY_ENTER || event.key === KEY_SPACE)) {
|
|
40
42
|
event.preventDefault();
|
|
41
43
|
if (isTabbing) {
|
|
42
44
|
event.stopPropagation();
|
|
43
45
|
}
|
|
44
46
|
onClick(value);
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
if (isTabbing) {
|
|
48
|
+
if (fg('platform_color_palette_menu_timeline_bar_a11y')) {
|
|
49
|
+
if (isColorPaletteMenu) {
|
|
50
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
|
|
51
|
+
} else if (event.key === KEY_TAB) {
|
|
52
52
|
event.stopPropagation();
|
|
53
|
+
event.preventDefault();
|
|
53
54
|
}
|
|
54
|
-
onClick === null || onClick === void 0 || onClick(value);
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
}, [isTabbing, onClick, onKeyDown, value]);
|
|
58
|
-
|
|
59
|
-
// TODO: Remove this useEffect when the feature flag 'platform_color_palette_menu_timeline_bar_a11y' is cleaned up
|
|
56
|
+
}, [isTabbing, isTabbingIgnored, isColorPaletteMenu, onClick, onKeyDown, value]);
|
|
60
57
|
useEffect(function () {
|
|
61
58
|
if (!fg('platform_color_palette_menu_timeline_bar_a11y')) {
|
|
62
59
|
var refCurrent = ref.current;
|
|
63
|
-
var handleTabKey = function handleTabKey(
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
var handleTabKey = function handleTabKey(event) {
|
|
61
|
+
if (event.key === KEY_TAB) {
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
event.preventDefault();
|
|
67
64
|
}
|
|
68
65
|
};
|
|
69
66
|
refCurrent === null || refCurrent === void 0 || refCurrent.addEventListener('keydown', handleTabKey);
|
|
@@ -75,7 +72,7 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
|
|
|
75
72
|
useImperativeHandle(componentRef, function () {
|
|
76
73
|
return {
|
|
77
74
|
focus: function focus() {
|
|
78
|
-
if (
|
|
75
|
+
if (isTabbingIgnored) {
|
|
79
76
|
if (isInitialFocus.current) {
|
|
80
77
|
var _ref$current;
|
|
81
78
|
!initialFocusRef && ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus());
|
|
@@ -87,7 +84,7 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
|
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
};
|
|
90
|
-
}, [initialFocusRef]);
|
|
87
|
+
}, [isTabbingIgnored, initialFocusRef]);
|
|
91
88
|
return jsx(Tooltip, {
|
|
92
89
|
content: label
|
|
93
90
|
}, function (tooltipProps) {
|
|
@@ -98,10 +95,10 @@ var ColorCard = /*#__PURE__*/forwardRef(function (props, componentRef) {
|
|
|
98
95
|
tabIndex: fg('platform_color_palette_menu_timeline_bar_a11y') ? selected ? 0 : -1 : 0,
|
|
99
96
|
"aria-checked": selected,
|
|
100
97
|
"aria-label": label,
|
|
101
|
-
css: [sharedColorContainerStyles, (isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && !isTabbing && colorCardOptionFocusedStyles],
|
|
98
|
+
css: [sharedColorContainerStyles, (isTabbingIgnored || isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && (isTabbingIgnored || !isTabbing) && colorCardOptionFocusedStyles],
|
|
102
99
|
onClick: handleClick,
|
|
103
100
|
onMouseDown: handleMouseDown,
|
|
104
|
-
onKeyDown:
|
|
101
|
+
onKeyDown: handleKeyDown
|
|
105
102
|
}), jsx("div", {
|
|
106
103
|
css: colorCardWrapperStyles
|
|
107
104
|
}, jsx("div", {
|
|
@@ -12,9 +12,12 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
12
12
|
import { getOptions, getWidth } from '../utils';
|
|
13
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
14
14
|
import { css, jsx } from '@emotion/react';
|
|
15
|
+
import { COLOR_PALETTE_MENU, KEY_ARROW_UP, KEY_ARROW_DOWN, KEY_ARROW_LEFT, KEY_ARROW_RIGHT, KEY_TAB } from '../constants';
|
|
15
16
|
import { N0, N40 } from '@atlaskit/theme/colors';
|
|
16
17
|
export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAnalytics(_ref) {
|
|
17
|
-
var
|
|
18
|
+
var _ref$isFocusLockEnabl = _ref.isFocusLockEnabled,
|
|
19
|
+
isFocusLockEnabled = _ref$isFocusLockEnabl === void 0 ? true : _ref$isFocusLockEnabl,
|
|
20
|
+
createAnalyticsEvent = _ref.createAnalyticsEvent,
|
|
18
21
|
onChange = _ref.onChange,
|
|
19
22
|
palette = _ref.palette,
|
|
20
23
|
selectedColor = _ref.selectedColor,
|
|
@@ -26,6 +29,18 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
26
29
|
_ref$mode = _ref.mode,
|
|
27
30
|
mode = _ref$mode === void 0 ? Mode.Standard : _ref$mode,
|
|
28
31
|
initialFocusRef = _ref.initialFocusRef;
|
|
32
|
+
var _getOptions = getOptions(palette, selectedColor),
|
|
33
|
+
options = _getOptions.options,
|
|
34
|
+
selectedValue = _getOptions.value;
|
|
35
|
+
var fullLabel = "".concat(label, ", ").concat(selectedValue.label, " selected");
|
|
36
|
+
var selectedColorIndex = selectedValue.value ? options.findIndex(function (_ref2) {
|
|
37
|
+
var value = _ref2.value;
|
|
38
|
+
return value === selectedValue.value;
|
|
39
|
+
}) : 0;
|
|
40
|
+
var _useState = useState(selectedColorIndex),
|
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
42
|
+
focusedIndex = _useState2[0],
|
|
43
|
+
setFocusedIndex = _useState2[1];
|
|
29
44
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
30
45
|
var changeAnalyticsCaller = function changeAnalyticsCaller() {
|
|
31
46
|
if (createAnalyticsEvent) {
|
|
@@ -35,7 +50,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
35
50
|
attributes: {
|
|
36
51
|
componentName: 'color-picker',
|
|
37
52
|
packageName: "@atlaskit/color-picker",
|
|
38
|
-
packageVersion: "3.
|
|
53
|
+
packageVersion: "3.3.0"
|
|
39
54
|
}
|
|
40
55
|
})(createAnalyticsEvent);
|
|
41
56
|
}
|
|
@@ -47,17 +62,6 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
47
62
|
var handleChange = function handleChange(value) {
|
|
48
63
|
onChange(value, changeAnalyticsCaller());
|
|
49
64
|
};
|
|
50
|
-
var _getOptions = getOptions(palette, selectedColor),
|
|
51
|
-
options = _getOptions.options,
|
|
52
|
-
selectedValue = _getOptions.value;
|
|
53
|
-
var fullLabel = "".concat(label, ", ").concat(selectedValue.label, " selected");
|
|
54
|
-
var _useState = useState(selectedValue.value ? options.findIndex(function (_ref2) {
|
|
55
|
-
var value = _ref2.value;
|
|
56
|
-
return value === selectedValue.value;
|
|
57
|
-
}) : 0),
|
|
58
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
-
focusedIndex = _useState2[0],
|
|
60
|
-
setFocusedIndex = _useState2[1];
|
|
61
65
|
useEffect(function () {
|
|
62
66
|
var _colorCardRefs$focuse;
|
|
63
67
|
(_colorCardRefs$focuse = colorCardRefs[focusedIndex]) === null || _colorCardRefs$focuse === void 0 || _colorCardRefs$focuse.focus();
|
|
@@ -65,22 +69,31 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
65
69
|
var handleKeyDown = useCallback(function (event) {
|
|
66
70
|
var numItems = options.length;
|
|
67
71
|
switch (event.key) {
|
|
68
|
-
case
|
|
69
|
-
case
|
|
72
|
+
case KEY_ARROW_DOWN:
|
|
73
|
+
case KEY_ARROW_RIGHT:
|
|
70
74
|
setFocusedIndex(function (prevIndex) {
|
|
71
75
|
return (prevIndex + 1) % numItems;
|
|
72
76
|
});
|
|
73
77
|
break;
|
|
74
|
-
case
|
|
75
|
-
case
|
|
78
|
+
case KEY_ARROW_UP:
|
|
79
|
+
case KEY_ARROW_LEFT:
|
|
76
80
|
setFocusedIndex(function (prevIndex) {
|
|
77
81
|
return (prevIndex - 1 + numItems) % numItems;
|
|
78
82
|
});
|
|
79
83
|
break;
|
|
84
|
+
case KEY_TAB:
|
|
85
|
+
{
|
|
86
|
+
if (isFocusLockEnabled) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
event.stopPropagation();
|
|
89
|
+
setFocusedIndex(selectedColorIndex);
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
80
93
|
default:
|
|
81
94
|
break;
|
|
82
95
|
}
|
|
83
|
-
}, [setFocusedIndex, options]);
|
|
96
|
+
}, [isFocusLockEnabled, selectedColorIndex, setFocusedIndex, options]);
|
|
84
97
|
return jsx("div", {
|
|
85
98
|
"aria-label": fullLabel,
|
|
86
99
|
role: fg('platform_color_palette_menu_timeline_bar_a11y') ? 'group' : 'radiogroup'
|
|
@@ -102,6 +115,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
102
115
|
css: colorCardWrapperStyles,
|
|
103
116
|
key: value
|
|
104
117
|
}, jsx(ColorCard, _extends({
|
|
118
|
+
type: COLOR_PALETTE_MENU,
|
|
105
119
|
label: label,
|
|
106
120
|
value: value,
|
|
107
121
|
checkMarkColor: checkMarkColor,
|
|
@@ -110,7 +124,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
110
124
|
onClick: handleChange
|
|
111
125
|
}, fg('platform_color_palette_menu_timeline_bar_a11y') && {
|
|
112
126
|
ref: function ref(_ref4) {
|
|
113
|
-
|
|
127
|
+
colorCardRefs[index] = _ref4;
|
|
114
128
|
},
|
|
115
129
|
initialFocusRef: value === selectedValue.value ? initialFocusRef : undefined,
|
|
116
130
|
onKeyDown: handleKeyDown
|
|
@@ -120,7 +134,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
120
134
|
export default withAnalyticsContext({
|
|
121
135
|
componentName: 'color-picker',
|
|
122
136
|
packageName: "@atlaskit/color-picker",
|
|
123
|
-
packageVersion: "3.
|
|
137
|
+
packageVersion: "3.3.0"
|
|
124
138
|
})(withAnalyticsEvents()(ColorPaletteMenuWithoutAnalytics));
|
|
125
139
|
var colorCardWrapperStyles = css({
|
|
126
140
|
display: 'flex',
|
|
@@ -6,7 +6,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
function _createSuper(
|
|
9
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
10
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
11
|
/**
|
|
12
12
|
* @jsxRuntime classic
|
|
@@ -16,7 +16,7 @@ import React from 'react';
|
|
|
16
16
|
import { PopupSelect } from '@atlaskit/select';
|
|
17
17
|
import Trigger from './Trigger';
|
|
18
18
|
import * as components from './components';
|
|
19
|
-
import { KEY_ARROW_DOWN, KEY_ARROW_UP, KEY_TAB } from '../constants';
|
|
19
|
+
import { KEY_ARROW_DOWN, KEY_ARROW_UP, KEY_TAB, KEY_ESCAPE } from '../constants';
|
|
20
20
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
21
21
|
import { getOptions } from '../utils';
|
|
22
22
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
@@ -34,7 +34,7 @@ var defaultPopperProps = {
|
|
|
34
34
|
placement: 'bottom-start'
|
|
35
35
|
};
|
|
36
36
|
var packageName = "@atlaskit/color-picker";
|
|
37
|
-
var packageVersion = "3.
|
|
37
|
+
var packageVersion = "3.3.0";
|
|
38
38
|
var ColorPickerWithoutAnalyticsBase = /*#__PURE__*/function (_React$Component) {
|
|
39
39
|
_inherits(ColorPickerWithoutAnalyticsBase, _React$Component);
|
|
40
40
|
var _super = _createSuper(ColorPickerWithoutAnalyticsBase);
|
|
@@ -80,7 +80,7 @@ var ColorPickerWithoutAnalyticsBase = /*#__PURE__*/function (_React$Component) {
|
|
|
80
80
|
_this.setState({
|
|
81
81
|
isTabbing: false
|
|
82
82
|
});
|
|
83
|
-
} else if (key ===
|
|
83
|
+
} else if (key === KEY_ESCAPE) {
|
|
84
84
|
e.stopPropagation();
|
|
85
85
|
}
|
|
86
86
|
});
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
6
|
import Tooltip from '@atlaskit/tooltip';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
9
|
import { css, jsx } from '@emotion/react';
|
|
9
10
|
import { B100, DN600A, N0 } from '@atlaskit/theme/colors';
|
|
@@ -29,7 +30,7 @@ var ColorCard = function ColorCard(_ref) {
|
|
|
29
30
|
return jsx(Tooltip, {
|
|
30
31
|
content: label
|
|
31
32
|
}, jsx("button", {
|
|
32
|
-
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
33
|
+
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && !fg('platform-design-system-dsp-20821-color-pickr-focus') && colorCardButtonFocusedStyles],
|
|
33
34
|
disabled: isDisabled,
|
|
34
35
|
onClick: handleClick,
|
|
35
36
|
onMouseDown: handleMouseDown,
|
|
@@ -9,6 +9,7 @@ import ColorCard from './ColorCard';
|
|
|
9
9
|
import { getWidth } from '../utils';
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { css, jsx } from '@emotion/react';
|
|
12
|
+
import { COLOR_PICKER } from '../constants';
|
|
12
13
|
export var MenuList = function MenuList(props) {
|
|
13
14
|
var cols = props.selectProps.cols,
|
|
14
15
|
innerRef = props.innerRef,
|
|
@@ -37,6 +38,7 @@ export var Option = function Option(props) {
|
|
|
37
38
|
return jsx("div", _extends({
|
|
38
39
|
css: colorCardWrapperStyles
|
|
39
40
|
}, innerProps), jsx(ColorCard, {
|
|
41
|
+
type: COLOR_PICKER,
|
|
40
42
|
label: label,
|
|
41
43
|
value: value,
|
|
42
44
|
checkMarkColor: checkMarkColor,
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
export var COLOR_PICKER = 'COLOR_PICKER';
|
|
2
|
+
export var COLOR_PALETTE_MENU = 'COLOR_PALETTE_MENU';
|
|
1
3
|
export var COLOR_CARD_SIZE = 32;
|
|
2
4
|
export var KEY_SPACE = ' ';
|
|
3
5
|
export var KEY_ENTER = 'Enter';
|
|
4
|
-
export var KEY_ARROW_UP = '
|
|
5
|
-
export var KEY_ARROW_DOWN = '
|
|
6
|
-
export var
|
|
6
|
+
export var KEY_ARROW_UP = 'ArrowUp';
|
|
7
|
+
export var KEY_ARROW_DOWN = 'ArrowDown';
|
|
8
|
+
export var KEY_ARROW_LEFT = 'ArrowLeft';
|
|
9
|
+
export var KEY_ARROW_RIGHT = 'ArrowRight';
|
|
10
|
+
export var KEY_TAB = 'Tab';
|
|
11
|
+
export var KEY_ESCAPE = 'Escape';
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import React, { type KeyboardEventHandler, type Ref } from 'react';
|
|
6
|
+
import type { ColorCardType } from '../types';
|
|
6
7
|
export interface Props {
|
|
7
8
|
initialFocusRef?: Ref<HTMLDivElement>;
|
|
9
|
+
type: ColorCardType;
|
|
8
10
|
value: string;
|
|
9
11
|
label: string;
|
|
10
12
|
onClick?: (value: string) => void;
|
|
@@ -6,6 +6,8 @@ import { type Ref } from 'react';
|
|
|
6
6
|
import { Mode, type Palette } from '../types';
|
|
7
7
|
import { jsx } from '@emotion/react';
|
|
8
8
|
export type Props = {
|
|
9
|
+
/** the toggle that decides if users can tab outside the color picker (arrow keys will always cycle the focus) */
|
|
10
|
+
isFocusLockEnabled?: boolean;
|
|
9
11
|
/** color picker button label */
|
|
10
12
|
label?: string;
|
|
11
13
|
/** list of available colors */
|
|
@@ -25,6 +27,6 @@ export type Props = {
|
|
|
25
27
|
/** the ref object (usually the currently selected color palette) that consumer can leverage to focus on load */
|
|
26
28
|
initialFocusRef?: Ref<HTMLDivElement>;
|
|
27
29
|
};
|
|
28
|
-
export declare const ColorPaletteMenuWithoutAnalytics: ({ createAnalyticsEvent, onChange, palette, selectedColor, checkMarkColor, label, cols, mode, initialFocusRef, }: Props) => jsx.JSX.Element;
|
|
29
|
-
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" | "mode"> & import("react").RefAttributes<any>>;
|
|
30
|
+
export declare const ColorPaletteMenuWithoutAnalytics: ({ isFocusLockEnabled, createAnalyticsEvent, onChange, palette, selectedColor, checkMarkColor, label, cols, mode, initialFocusRef, }: Props) => jsx.JSX.Element;
|
|
31
|
+
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" | "mode"> & import("react").RefAttributes<any>>;
|
|
30
32
|
export default _default;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
export declare const COLOR_PICKER = "COLOR_PICKER";
|
|
2
|
+
export declare const COLOR_PALETTE_MENU = "COLOR_PALETTE_MENU";
|
|
1
3
|
export declare const COLOR_CARD_SIZE = 32;
|
|
2
4
|
export declare const KEY_SPACE = " ";
|
|
3
5
|
export declare const KEY_ENTER = "Enter";
|
|
4
|
-
export declare const KEY_ARROW_UP = "
|
|
5
|
-
export declare const KEY_ARROW_DOWN = "
|
|
6
|
+
export declare const KEY_ARROW_UP = "ArrowUp";
|
|
7
|
+
export declare const KEY_ARROW_DOWN = "ArrowDown";
|
|
8
|
+
export declare const KEY_ARROW_LEFT = "ArrowLeft";
|
|
9
|
+
export declare const KEY_ARROW_RIGHT = "ArrowRight";
|
|
6
10
|
export declare const KEY_TAB = "Tab";
|
|
11
|
+
export declare const KEY_ESCAPE = "Escape";
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import React, { type KeyboardEventHandler, type Ref } from 'react';
|
|
6
|
+
import type { ColorCardType } from '../types';
|
|
6
7
|
export interface Props {
|
|
7
8
|
initialFocusRef?: Ref<HTMLDivElement>;
|
|
9
|
+
type: ColorCardType;
|
|
8
10
|
value: string;
|
|
9
11
|
label: string;
|
|
10
12
|
onClick?: (value: string) => void;
|
|
@@ -6,6 +6,8 @@ import { type Ref } from 'react';
|
|
|
6
6
|
import { Mode, type Palette } from '../types';
|
|
7
7
|
import { jsx } from '@emotion/react';
|
|
8
8
|
export type Props = {
|
|
9
|
+
/** the toggle that decides if users can tab outside the color picker (arrow keys will always cycle the focus) */
|
|
10
|
+
isFocusLockEnabled?: boolean;
|
|
9
11
|
/** color picker button label */
|
|
10
12
|
label?: string;
|
|
11
13
|
/** list of available colors */
|
|
@@ -25,6 +27,6 @@ export type Props = {
|
|
|
25
27
|
/** the ref object (usually the currently selected color palette) that consumer can leverage to focus on load */
|
|
26
28
|
initialFocusRef?: Ref<HTMLDivElement>;
|
|
27
29
|
};
|
|
28
|
-
export declare const ColorPaletteMenuWithoutAnalytics: ({ createAnalyticsEvent, onChange, palette, selectedColor, checkMarkColor, label, cols, mode, initialFocusRef, }: Props) => jsx.JSX.Element;
|
|
29
|
-
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" | "mode"> & import("react").RefAttributes<any>>;
|
|
30
|
+
export declare const ColorPaletteMenuWithoutAnalytics: ({ isFocusLockEnabled, createAnalyticsEvent, onChange, palette, selectedColor, checkMarkColor, label, cols, mode, initialFocusRef, }: Props) => jsx.JSX.Element;
|
|
31
|
+
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" | "mode"> & import("react").RefAttributes<any>>;
|
|
30
32
|
export default _default;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
export declare const COLOR_PICKER = "COLOR_PICKER";
|
|
2
|
+
export declare const COLOR_PALETTE_MENU = "COLOR_PALETTE_MENU";
|
|
1
3
|
export declare const COLOR_CARD_SIZE = 32;
|
|
2
4
|
export declare const KEY_SPACE = " ";
|
|
3
5
|
export declare const KEY_ENTER = "Enter";
|
|
4
|
-
export declare const KEY_ARROW_UP = "
|
|
5
|
-
export declare const KEY_ARROW_DOWN = "
|
|
6
|
+
export declare const KEY_ARROW_UP = "ArrowUp";
|
|
7
|
+
export declare const KEY_ARROW_DOWN = "ArrowDown";
|
|
8
|
+
export declare const KEY_ARROW_LEFT = "ArrowLeft";
|
|
9
|
+
export declare const KEY_ARROW_RIGHT = "ArrowRight";
|
|
6
10
|
export declare const KEY_TAB = "Tab";
|
|
11
|
+
export declare const KEY_ESCAPE = "Escape";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/color-picker",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Jira Color Picker Component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
"atlaskit:src": "src/index.ts",
|
|
24
24
|
"atlassian": {
|
|
25
25
|
"team": "AAIS: Chronos",
|
|
26
|
-
"releaseModel": "continuous",
|
|
27
|
-
"productPushConsumption": [
|
|
28
|
-
"jira"
|
|
29
|
-
],
|
|
30
26
|
"website": {
|
|
31
27
|
"name": "Color Picker"
|
|
32
28
|
},
|
|
@@ -34,9 +30,9 @@
|
|
|
34
30
|
},
|
|
35
31
|
"dependencies": {
|
|
36
32
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
37
|
-
"@atlaskit/icon": "^22.
|
|
33
|
+
"@atlaskit/icon": "^22.18.0",
|
|
38
34
|
"@atlaskit/platform-feature-flags": "0.3.0",
|
|
39
|
-
"@atlaskit/select": "^17.
|
|
35
|
+
"@atlaskit/select": "^17.18.0",
|
|
40
36
|
"@atlaskit/theme": "^13.0.0",
|
|
41
37
|
"@atlaskit/tokens": "^1.59.0",
|
|
42
38
|
"@atlaskit/tooltip": "^18.7.0",
|
|
@@ -47,11 +43,11 @@
|
|
|
47
43
|
"use-callback-ref": "^1.2.3"
|
|
48
44
|
},
|
|
49
45
|
"peerDependencies": {
|
|
50
|
-
"react": "^16.8.0"
|
|
46
|
+
"react": "^16.8.0 || ^17.0.0 || ~18.2.0"
|
|
51
47
|
},
|
|
52
48
|
"devDependencies": {
|
|
53
49
|
"@af/visual-regression": "*",
|
|
54
|
-
"@atlaskit/primitives": "^12.
|
|
50
|
+
"@atlaskit/primitives": "^12.1.0",
|
|
55
51
|
"@atlaskit/visual-regression": "*",
|
|
56
52
|
"@testing-library/react": "^12.1.5",
|
|
57
53
|
"@testing-library/user-event": "^14.4.3",
|
|
@@ -81,6 +77,9 @@
|
|
|
81
77
|
"platform-feature-flags": {
|
|
82
78
|
"platform_color_palette_menu_timeline_bar_a11y": {
|
|
83
79
|
"type": "boolean"
|
|
80
|
+
},
|
|
81
|
+
"platform-design-system-dsp-20821-color-pickr-focus": {
|
|
82
|
+
"type": "boolean"
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
}
|