@atlaskit/color-picker 3.2.4 → 3.2.6
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 +12 -0
- package/dist/cjs/components/ColorCard.js +23 -2
- package/dist/cjs/components/ColorPaletteMenu.js +2 -2
- package/dist/cjs/components/ColorPicker.js +14 -4
- package/dist/cjs/components/Trigger.js +39 -12
- package/dist/cjs/utils.js +10 -2
- package/dist/es2019/components/ColorCard.js +24 -3
- package/dist/es2019/components/ColorPaletteMenu.js +2 -2
- package/dist/es2019/components/ColorPicker.js +13 -4
- package/dist/es2019/components/Trigger.js +38 -12
- package/dist/es2019/utils.js +10 -2
- package/dist/esm/components/ColorCard.js +24 -3
- package/dist/esm/components/ColorPaletteMenu.js +2 -2
- package/dist/esm/components/ColorPicker.js +14 -4
- package/dist/esm/components/Trigger.js +39 -12
- package/dist/esm/utils.js +10 -2
- package/dist/types/components/ColorPicker.d.ts +8 -2
- package/dist/types/components/Trigger.d.ts +4 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/utils.d.ts +1 -1
- package/dist/types-ts4.5/components/ColorPicker.d.ts +8 -2
- package/dist/types-ts4.5/components/Trigger.d.ts +4 -1
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/utils.d.ts +1 -1
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/color-picker
|
|
2
2
|
|
|
3
|
+
## 3.2.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#83297](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83297) [`6b1707c169e0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6b1707c169e0) - The internal composition of this component has changed. There is no expected change in behaviour.
|
|
8
|
+
|
|
9
|
+
## 3.2.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#81931](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/81931) [`fd212c03b3c4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fd212c03b3c4) - Implemented code to modify the size, set a default color, and disable the swatch color button, based on the new props passed to the component.
|
|
14
|
+
|
|
3
15
|
## 3.2.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _done = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/done"));
|
|
11
12
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
12
13
|
var _constants = require("../constants");
|
|
13
14
|
var _react2 = require("@emotion/react");
|
|
14
15
|
var _colors = require("@atlaskit/theme/colors");
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
17
|
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); }
|
|
16
18
|
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 && Object.prototype.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; }
|
|
17
19
|
/** @jsx jsx */
|
|
@@ -26,6 +28,7 @@ var ColorCard = function ColorCard(props) {
|
|
|
26
28
|
isTabbing = props.isTabbing,
|
|
27
29
|
onClick = props.onClick,
|
|
28
30
|
onKeyDown = props.onKeyDown;
|
|
31
|
+
var ref = (0, _react.useRef)(null);
|
|
29
32
|
var handleMouseDown = (0, _react.useCallback)(function (event) {
|
|
30
33
|
event.preventDefault();
|
|
31
34
|
}, []);
|
|
@@ -45,9 +48,24 @@ var ColorCard = function ColorCard(props) {
|
|
|
45
48
|
onKeyDown(value);
|
|
46
49
|
}
|
|
47
50
|
}, [isTabbing, onKeyDown, value]);
|
|
51
|
+
(0, _react.useEffect)(function () {
|
|
52
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.color-picker-radio-button-functionality_6hkcy')) {
|
|
53
|
+
var refCurrent = ref.current;
|
|
54
|
+
var _handleKeyDown = function _handleKeyDown(e) {
|
|
55
|
+
if (e.key === 'Tab') {
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
refCurrent === null || refCurrent === void 0 || refCurrent.addEventListener('keydown', _handleKeyDown);
|
|
61
|
+
return function () {
|
|
62
|
+
refCurrent === null || refCurrent === void 0 || refCurrent.removeEventListener('keydown', _handleKeyDown);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
48
66
|
return (0, _react2.jsx)(_tooltip.default, {
|
|
49
67
|
content: label
|
|
50
|
-
}, (0, _react2.jsx)("div", {
|
|
68
|
+
}, (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
51
69
|
css: [sharedColorContainerStyles, (isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && !isTabbing && colorCardOptionFocusedStyles],
|
|
52
70
|
onClick: handleClick,
|
|
53
71
|
onMouseDown: handleMouseDown,
|
|
@@ -56,7 +74,9 @@ var ColorCard = function ColorCard(props) {
|
|
|
56
74
|
"aria-checked": selected,
|
|
57
75
|
"aria-label": label,
|
|
58
76
|
tabIndex: 0
|
|
59
|
-
}, (0,
|
|
77
|
+
}, (0, _platformFeatureFlags.getBooleanFF)('platform.color-picker-radio-button-functionality_6hkcy') && {
|
|
78
|
+
ref: ref
|
|
79
|
+
}), (0, _react2.jsx)("div", {
|
|
60
80
|
css: colorCardContentStyles,
|
|
61
81
|
style: {
|
|
62
82
|
background: value || 'transparent'
|
|
@@ -102,5 +122,6 @@ var colorCardContentStyles = (0, _react2.css)({
|
|
|
102
122
|
boxShadow: "inset 0px 0px 0px 1px ".concat("var(--ds-background-inverse-subtle, ".concat(_colors.DN600A, ")"))
|
|
103
123
|
});
|
|
104
124
|
var colorCardContentCheckMarkStyles = (0, _react2.css)({
|
|
125
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
105
126
|
margin: '1px'
|
|
106
127
|
});
|
|
@@ -35,7 +35,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
35
35
|
attributes: {
|
|
36
36
|
componentName: 'color-picker',
|
|
37
37
|
packageName: "@atlaskit/color-picker",
|
|
38
|
-
packageVersion: "3.2.
|
|
38
|
+
packageVersion: "3.2.6"
|
|
39
39
|
}
|
|
40
40
|
})(createAnalyticsEvent);
|
|
41
41
|
}
|
|
@@ -77,7 +77,7 @@ var ColorPaletteMenuWithoutAnalytics = exports.ColorPaletteMenuWithoutAnalytics
|
|
|
77
77
|
var _default = exports.default = (0, _analyticsNext.withAnalyticsContext)({
|
|
78
78
|
componentName: 'color-picker',
|
|
79
79
|
packageName: "@atlaskit/color-picker",
|
|
80
|
-
packageVersion: "3.2.
|
|
80
|
+
packageVersion: "3.2.6"
|
|
81
81
|
})((0, _analyticsNext.withAnalyticsEvents)()(ColorPaletteMenuWithoutAnalytics));
|
|
82
82
|
var colorCardWrapperStyles = (0, _react.css)({
|
|
83
83
|
display: 'flex',
|
|
@@ -22,6 +22,7 @@ var _constants = require("../constants");
|
|
|
22
22
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
23
23
|
var _utils = require("../utils");
|
|
24
24
|
var _react2 = require("@emotion/react");
|
|
25
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
25
26
|
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); }
|
|
26
27
|
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 && Object.prototype.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; }
|
|
27
28
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
@@ -37,7 +38,7 @@ var defaultPopperProps = {
|
|
|
37
38
|
placement: 'bottom-start'
|
|
38
39
|
};
|
|
39
40
|
var packageName = "@atlaskit/color-picker";
|
|
40
|
-
var packageVersion = "3.2.
|
|
41
|
+
var packageVersion = "3.2.6";
|
|
41
42
|
var ColorPickerWithoutAnalytics = exports.ColorPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
42
43
|
(0, _inherits2.default)(ColorPickerWithoutAnalytics, _React$Component);
|
|
43
44
|
var _super = _createSuper(ColorPickerWithoutAnalytics);
|
|
@@ -83,6 +84,8 @@ var ColorPickerWithoutAnalytics = exports.ColorPickerWithoutAnalytics = /*#__PUR
|
|
|
83
84
|
_this.setState({
|
|
84
85
|
isTabbing: false
|
|
85
86
|
});
|
|
87
|
+
} else if ((0, _platformFeatureFlags.getBooleanFF)('platform.color-picker-radio-button-functionality_6hkcy') && key === 'Escape') {
|
|
88
|
+
e.stopPropagation();
|
|
86
89
|
}
|
|
87
90
|
});
|
|
88
91
|
return _this;
|
|
@@ -98,11 +101,15 @@ var ColorPickerWithoutAnalytics = exports.ColorPickerWithoutAnalytics = /*#__PUR
|
|
|
98
101
|
_this$props$popperPro = _this$props.popperProps,
|
|
99
102
|
popperProps = _this$props$popperPro === void 0 ? defaultPopperProps : _this$props$popperPro,
|
|
100
103
|
_this$props$label = _this$props.label,
|
|
101
|
-
label = _this$props$label === void 0 ? 'Color picker' : _this$props$label
|
|
102
|
-
|
|
104
|
+
label = _this$props$label === void 0 ? 'Color picker' : _this$props$label,
|
|
105
|
+
selectedColourSwatchSize = _this$props.selectedColourSwatchSize,
|
|
106
|
+
_this$props$showDefau = _this$props.showDefaultSwatchColor,
|
|
107
|
+
showDefaultSwatchColor = _this$props$showDefau === void 0 ? true : _this$props$showDefau,
|
|
108
|
+
isDisabledSelectedSwatch = _this$props.isDisabledSelectedSwatch;
|
|
109
|
+
var _getOptions = (0, _utils.getOptions)(palette, selectedColor, showDefaultSwatchColor),
|
|
103
110
|
options = _getOptions.options,
|
|
104
111
|
value = _getOptions.value;
|
|
105
|
-
var fullLabel = "".concat(label, ", ").concat(value.label, " selected");
|
|
112
|
+
var fullLabel = value.label && "".concat(label, ", ").concat(value.label, " selected");
|
|
106
113
|
return (0, _react2.jsx)(_select.PopupSelect, {
|
|
107
114
|
target: function target(_ref) {
|
|
108
115
|
var ref = _ref.ref,
|
|
@@ -113,6 +120,9 @@ var ColorPickerWithoutAnalytics = exports.ColorPickerWithoutAnalytics = /*#__PUR
|
|
|
113
120
|
}, (0, _react2.jsx)(_Trigger.default, (0, _extends2.default)({}, value, {
|
|
114
121
|
label: fullLabel,
|
|
115
122
|
expanded: isOpen
|
|
123
|
+
}, (0, _platformFeatureFlags.getBooleanFF)('platform.color-picker-radio-button-functionality_6hkcy') && {
|
|
124
|
+
swatchSize: selectedColourSwatchSize,
|
|
125
|
+
isDisabled: isDisabledSelectedSwatch
|
|
116
126
|
})));
|
|
117
127
|
},
|
|
118
128
|
popperProps: popperProps,
|
|
@@ -5,18 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
9
|
var _react = require("react");
|
|
9
10
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
10
11
|
var _react2 = require("@emotion/react");
|
|
11
12
|
var _constants = require("../constants");
|
|
12
13
|
var _colors = require("@atlaskit/theme/colors");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
15
|
/** @jsx jsx */
|
|
14
16
|
|
|
15
17
|
var ColorCard = function ColorCard(_ref) {
|
|
16
18
|
var value = _ref.value,
|
|
17
19
|
label = _ref.label,
|
|
18
20
|
expanded = _ref.expanded,
|
|
19
|
-
onClick = _ref.onClick
|
|
21
|
+
onClick = _ref.onClick,
|
|
22
|
+
_ref$swatchSize = _ref.swatchSize,
|
|
23
|
+
swatchSize = _ref$swatchSize === void 0 ? 'default' : _ref$swatchSize,
|
|
24
|
+
isDisabled = _ref.isDisabled;
|
|
20
25
|
var handleMouseDown = (0, _react.useCallback)(function (event) {
|
|
21
26
|
event.preventDefault();
|
|
22
27
|
}, []);
|
|
@@ -29,27 +34,32 @@ var ColorCard = function ColorCard(_ref) {
|
|
|
29
34
|
}, [onClick]);
|
|
30
35
|
return (0, _react2.jsx)(_tooltip.default, {
|
|
31
36
|
content: label
|
|
32
|
-
}, (0, _react2.jsx)("button", {
|
|
33
|
-
css: [sharedColorContainerStyles, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
37
|
+
}, (0, _react2.jsx)("button", (0, _extends2.default)({}, (0, _platformFeatureFlags.getBooleanFF)('platform.color-picker-radio-button-functionality_6hkcy') ? {
|
|
38
|
+
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
39
|
+
disabled: isDisabled
|
|
40
|
+
} : {
|
|
41
|
+
css: [sharedColorContainerStyles, defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles]
|
|
42
|
+
}, {
|
|
34
43
|
onClick: handleClick,
|
|
35
44
|
onMouseDown: handleMouseDown,
|
|
36
45
|
"aria-label": label,
|
|
37
46
|
"aria-expanded": expanded,
|
|
38
47
|
"aria-haspopup": true,
|
|
39
48
|
type: "button"
|
|
40
|
-
}, (0, _react2.jsx)("span", {
|
|
41
|
-
css: colorCardContentStyles,
|
|
49
|
+
}), (0, _react2.jsx)("span", (0, _extends2.default)({}, (0, _platformFeatureFlags.getBooleanFF)('platform.color-picker-radio-button-functionality_6hkcy') ? {
|
|
50
|
+
css: [colorCardContentStyles, swatchSize === 'small' ? smallColorCardContentSize : defaultColorCardContentSize]
|
|
51
|
+
} : {
|
|
52
|
+
css: [colorCardContentStyles, defaultColorCardContentSize]
|
|
53
|
+
}, {
|
|
42
54
|
style: {
|
|
43
55
|
background: value || 'transparent'
|
|
44
56
|
}
|
|
45
|
-
})));
|
|
57
|
+
}))));
|
|
46
58
|
};
|
|
47
59
|
var _default = exports.default = ColorCard;
|
|
48
60
|
var sharedColorContainerStyles = (0, _react2.css)({
|
|
49
61
|
display: 'inline-block',
|
|
50
62
|
position: 'relative',
|
|
51
|
-
width: "".concat(_constants.COLOR_CARD_SIZE, "px"),
|
|
52
|
-
height: "".concat(_constants.COLOR_CARD_SIZE, "px"),
|
|
53
63
|
border: '2px solid transparent',
|
|
54
64
|
boxSizing: 'border-box',
|
|
55
65
|
borderRadius: '6px',
|
|
@@ -60,23 +70,40 @@ var sharedColorContainerStyles = (0, _react2.css)({
|
|
|
60
70
|
cursor: 'pointer',
|
|
61
71
|
outline: 'none'
|
|
62
72
|
});
|
|
73
|
+
var smallColorContainerSize = (0, _react2.css)({
|
|
74
|
+
width: '22px',
|
|
75
|
+
height: '22px',
|
|
76
|
+
top: "var(--ds-space-negative-025, -2px)"
|
|
77
|
+
});
|
|
78
|
+
var defaultColorContainerSize = (0, _react2.css)({
|
|
79
|
+
width: "".concat(_constants.COLOR_CARD_SIZE, "px"),
|
|
80
|
+
height: "".concat(_constants.COLOR_CARD_SIZE, "px")
|
|
81
|
+
});
|
|
63
82
|
var colorCardButtonStyles = (0, _react2.css)({
|
|
64
83
|
':hover': {
|
|
65
84
|
borderColor: "var(--ds-background-neutral-subtle, ".concat(_colors.N0, ")")
|
|
66
85
|
},
|
|
67
86
|
':not(:focus):hover, :focus': {
|
|
68
|
-
borderColor: "var(--ds-border-focused, ".concat(_colors.B100, ")")
|
|
87
|
+
borderColor: "var(--ds-border-focused, ".concat(_colors.B100, ")"),
|
|
88
|
+
outline: 'none'
|
|
69
89
|
}
|
|
70
90
|
});
|
|
71
91
|
var colorCardButtonFocusedStyles = (0, _react2.css)({
|
|
72
|
-
borderColor: "var(--ds-border-focused, ".concat(_colors.B100, ")")
|
|
92
|
+
borderColor: "var(--ds-border-focused, ".concat(_colors.B100, ")"),
|
|
93
|
+
outline: 'none'
|
|
73
94
|
});
|
|
74
95
|
var colorCardContentStyles = (0, _react2.css)({
|
|
75
96
|
position: 'absolute',
|
|
76
97
|
top: '1px',
|
|
77
98
|
left: '1px',
|
|
78
|
-
width: "var(--ds-space-300, 24px)",
|
|
79
|
-
height: "var(--ds-space-300, 24px)",
|
|
80
99
|
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
81
100
|
boxShadow: "inset 0px 0px 0px 1px ".concat("var(--ds-background-inverse-subtle, ".concat(_colors.DN600A, ")"))
|
|
101
|
+
});
|
|
102
|
+
var smallColorCardContentSize = (0, _react2.css)({
|
|
103
|
+
width: "var(--ds-space-200, 16px)",
|
|
104
|
+
height: "var(--ds-space-200, 16px)"
|
|
105
|
+
});
|
|
106
|
+
var defaultColorCardContentSize = (0, _react2.css)({
|
|
107
|
+
width: "var(--ds-space-300, 24px)",
|
|
108
|
+
height: "var(--ds-space-300, 24px)"
|
|
82
109
|
});
|
package/dist/cjs/utils.js
CHANGED
|
@@ -9,6 +9,7 @@ var _theme = require("@atlaskit/theme");
|
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
11
11
|
var _types = require("./types");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
// AFP-2532 TODO: Fix automatic suppressions below
|
|
13
14
|
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
14
15
|
|
|
@@ -16,15 +17,22 @@ var getWidth = exports.getWidth = function getWidth(cols, mode) {
|
|
|
16
17
|
var width = cols * (_constants.COLOR_CARD_SIZE + (0, _theme.gridSize)() / 2);
|
|
17
18
|
return mode === _types.Mode.Standard ? width + (0, _theme.gridSize)() : width;
|
|
18
19
|
};
|
|
19
|
-
var getOptions = exports.getOptions = (0, _memoizeOne.default)(function (palette, selectedColor) {
|
|
20
|
+
var getOptions = exports.getOptions = (0, _memoizeOne.default)(function (palette, selectedColor, showDefaultSwatchColor) {
|
|
20
21
|
var focusedItemIndex = 0;
|
|
22
|
+
var defaultSelectedColor = palette[0];
|
|
23
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.color-picker-radio-button-functionality_6hkcy') && !showDefaultSwatchColor) {
|
|
24
|
+
defaultSelectedColor = {
|
|
25
|
+
label: '',
|
|
26
|
+
value: ''
|
|
27
|
+
};
|
|
28
|
+
}
|
|
21
29
|
var value = palette.find(function (color, index) {
|
|
22
30
|
if (color.value === selectedColor) {
|
|
23
31
|
focusedItemIndex = index;
|
|
24
32
|
return true;
|
|
25
33
|
}
|
|
26
34
|
return false;
|
|
27
|
-
}) ||
|
|
35
|
+
}) || defaultSelectedColor;
|
|
28
36
|
return {
|
|
29
37
|
options: palette,
|
|
30
38
|
value: value,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
/** @jsx jsx */
|
|
2
|
-
import React, { useCallback } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
3
4
|
import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
|
|
4
5
|
import Tooltip from '@atlaskit/tooltip';
|
|
5
6
|
import { COLOR_CARD_SIZE, KEY_ENTER, KEY_SPACE } from '../constants';
|
|
6
7
|
import { css, jsx } from '@emotion/react';
|
|
7
8
|
import { N0, DN600A, B75 } from '@atlaskit/theme/colors';
|
|
9
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
10
|
const ColorCard = props => {
|
|
9
11
|
const {
|
|
10
12
|
value,
|
|
@@ -17,6 +19,7 @@ const ColorCard = props => {
|
|
|
17
19
|
onClick,
|
|
18
20
|
onKeyDown
|
|
19
21
|
} = props;
|
|
22
|
+
const ref = useRef(null);
|
|
20
23
|
const handleMouseDown = useCallback(event => {
|
|
21
24
|
event.preventDefault();
|
|
22
25
|
}, []);
|
|
@@ -38,9 +41,24 @@ const ColorCard = props => {
|
|
|
38
41
|
onKeyDown(value);
|
|
39
42
|
}
|
|
40
43
|
}, [isTabbing, onKeyDown, value]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy')) {
|
|
46
|
+
const refCurrent = ref.current;
|
|
47
|
+
const handleKeyDown = e => {
|
|
48
|
+
if (e.key === 'Tab') {
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
refCurrent === null || refCurrent === void 0 ? void 0 : refCurrent.addEventListener('keydown', handleKeyDown);
|
|
54
|
+
return () => {
|
|
55
|
+
refCurrent === null || refCurrent === void 0 ? void 0 : refCurrent.removeEventListener('keydown', handleKeyDown);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}, []);
|
|
41
59
|
return jsx(Tooltip, {
|
|
42
60
|
content: label
|
|
43
|
-
}, jsx("div", {
|
|
61
|
+
}, jsx("div", _extends({
|
|
44
62
|
css: [sharedColorContainerStyles, (isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && !isTabbing && colorCardOptionFocusedStyles],
|
|
45
63
|
onClick: handleClick,
|
|
46
64
|
onMouseDown: handleMouseDown,
|
|
@@ -49,7 +67,9 @@ const ColorCard = props => {
|
|
|
49
67
|
"aria-checked": selected,
|
|
50
68
|
"aria-label": label,
|
|
51
69
|
tabIndex: 0
|
|
52
|
-
},
|
|
70
|
+
}, getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') && {
|
|
71
|
+
ref: ref
|
|
72
|
+
}), jsx("div", {
|
|
53
73
|
css: colorCardContentStyles,
|
|
54
74
|
style: {
|
|
55
75
|
background: value || 'transparent'
|
|
@@ -95,5 +115,6 @@ const colorCardContentStyles = css({
|
|
|
95
115
|
boxShadow: `inset 0px 0px 0px 1px ${`var(--ds-background-inverse-subtle, ${DN600A})`}`
|
|
96
116
|
});
|
|
97
117
|
const colorCardContentCheckMarkStyles = css({
|
|
118
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
98
119
|
margin: '1px'
|
|
99
120
|
});
|
|
@@ -25,7 +25,7 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
25
25
|
attributes: {
|
|
26
26
|
componentName: 'color-picker',
|
|
27
27
|
packageName: "@atlaskit/color-picker",
|
|
28
|
-
packageVersion: "3.2.
|
|
28
|
+
packageVersion: "3.2.6"
|
|
29
29
|
}
|
|
30
30
|
})(createAnalyticsEvent);
|
|
31
31
|
}
|
|
@@ -67,7 +67,7 @@ export const ColorPaletteMenuWithoutAnalytics = ({
|
|
|
67
67
|
export default withAnalyticsContext({
|
|
68
68
|
componentName: 'color-picker',
|
|
69
69
|
packageName: "@atlaskit/color-picker",
|
|
70
|
-
packageVersion: "3.2.
|
|
70
|
+
packageVersion: "3.2.6"
|
|
71
71
|
})(withAnalyticsEvents()(ColorPaletteMenuWithoutAnalytics));
|
|
72
72
|
const colorCardWrapperStyles = css({
|
|
73
73
|
display: 'flex',
|
|
@@ -9,6 +9,7 @@ import { KEY_ARROW_DOWN, KEY_ARROW_UP, KEY_TAB } from '../constants';
|
|
|
9
9
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
10
10
|
import { getOptions } from '../utils';
|
|
11
11
|
import { css, jsx } from '@emotion/react';
|
|
12
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
const defaultPopperProps = {
|
|
13
14
|
strategy: 'fixed',
|
|
14
15
|
modifiers: [{
|
|
@@ -20,7 +21,7 @@ const defaultPopperProps = {
|
|
|
20
21
|
placement: 'bottom-start'
|
|
21
22
|
};
|
|
22
23
|
const packageName = "@atlaskit/color-picker";
|
|
23
|
-
const packageVersion = "3.2.
|
|
24
|
+
const packageVersion = "3.2.6";
|
|
24
25
|
export class ColorPickerWithoutAnalytics extends React.Component {
|
|
25
26
|
constructor(...args) {
|
|
26
27
|
super(...args);
|
|
@@ -61,6 +62,8 @@ export class ColorPickerWithoutAnalytics extends React.Component {
|
|
|
61
62
|
this.setState({
|
|
62
63
|
isTabbing: false
|
|
63
64
|
});
|
|
65
|
+
} else if (getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') && key === 'Escape') {
|
|
66
|
+
e.stopPropagation();
|
|
64
67
|
}
|
|
65
68
|
});
|
|
66
69
|
}
|
|
@@ -71,13 +74,16 @@ export class ColorPickerWithoutAnalytics extends React.Component {
|
|
|
71
74
|
checkMarkColor,
|
|
72
75
|
cols,
|
|
73
76
|
popperProps = defaultPopperProps,
|
|
74
|
-
label = 'Color picker'
|
|
77
|
+
label = 'Color picker',
|
|
78
|
+
selectedColourSwatchSize,
|
|
79
|
+
showDefaultSwatchColor = true,
|
|
80
|
+
isDisabledSelectedSwatch
|
|
75
81
|
} = this.props;
|
|
76
82
|
const {
|
|
77
83
|
options,
|
|
78
84
|
value
|
|
79
|
-
} = getOptions(palette, selectedColor);
|
|
80
|
-
const fullLabel = `${label}, ${value.label} selected`;
|
|
85
|
+
} = getOptions(palette, selectedColor, showDefaultSwatchColor);
|
|
86
|
+
const fullLabel = value.label && `${label}, ${value.label} selected`;
|
|
81
87
|
return jsx(PopupSelect, {
|
|
82
88
|
target: ({
|
|
83
89
|
ref,
|
|
@@ -88,6 +94,9 @@ export class ColorPickerWithoutAnalytics extends React.Component {
|
|
|
88
94
|
}, jsx(Trigger, _extends({}, value, {
|
|
89
95
|
label: fullLabel,
|
|
90
96
|
expanded: isOpen
|
|
97
|
+
}, getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') && {
|
|
98
|
+
swatchSize: selectedColourSwatchSize,
|
|
99
|
+
isDisabled: isDisabledSelectedSwatch
|
|
91
100
|
}))),
|
|
92
101
|
popperProps: popperProps,
|
|
93
102
|
maxMenuWidth: "auto",
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
/** @jsx jsx */
|
|
2
3
|
import { useCallback } from 'react';
|
|
3
4
|
import Tooltip from '@atlaskit/tooltip';
|
|
4
5
|
import { css, jsx } from '@emotion/react';
|
|
5
6
|
import { COLOR_CARD_SIZE } from '../constants';
|
|
6
7
|
import { B100, DN600A, N0 } from '@atlaskit/theme/colors';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
9
|
const ColorCard = ({
|
|
8
10
|
value,
|
|
9
11
|
label,
|
|
10
12
|
expanded,
|
|
11
|
-
onClick
|
|
13
|
+
onClick,
|
|
14
|
+
swatchSize = 'default',
|
|
15
|
+
isDisabled
|
|
12
16
|
}) => {
|
|
13
17
|
const handleMouseDown = useCallback(event => {
|
|
14
18
|
event.preventDefault();
|
|
@@ -22,27 +26,32 @@ const ColorCard = ({
|
|
|
22
26
|
}, [onClick]);
|
|
23
27
|
return jsx(Tooltip, {
|
|
24
28
|
content: label
|
|
25
|
-
}, jsx("button", {
|
|
26
|
-
css: [sharedColorContainerStyles, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
29
|
+
}, jsx("button", _extends({}, getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') ? {
|
|
30
|
+
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
31
|
+
disabled: isDisabled
|
|
32
|
+
} : {
|
|
33
|
+
css: [sharedColorContainerStyles, defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles]
|
|
34
|
+
}, {
|
|
27
35
|
onClick: handleClick,
|
|
28
36
|
onMouseDown: handleMouseDown,
|
|
29
37
|
"aria-label": label,
|
|
30
38
|
"aria-expanded": expanded,
|
|
31
39
|
"aria-haspopup": true,
|
|
32
40
|
type: "button"
|
|
33
|
-
}, jsx("span", {
|
|
34
|
-
css: colorCardContentStyles,
|
|
41
|
+
}), jsx("span", _extends({}, getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') ? {
|
|
42
|
+
css: [colorCardContentStyles, swatchSize === 'small' ? smallColorCardContentSize : defaultColorCardContentSize]
|
|
43
|
+
} : {
|
|
44
|
+
css: [colorCardContentStyles, defaultColorCardContentSize]
|
|
45
|
+
}, {
|
|
35
46
|
style: {
|
|
36
47
|
background: value || 'transparent'
|
|
37
48
|
}
|
|
38
|
-
})));
|
|
49
|
+
}))));
|
|
39
50
|
};
|
|
40
51
|
export default ColorCard;
|
|
41
52
|
const sharedColorContainerStyles = css({
|
|
42
53
|
display: 'inline-block',
|
|
43
54
|
position: 'relative',
|
|
44
|
-
width: `${COLOR_CARD_SIZE}px`,
|
|
45
|
-
height: `${COLOR_CARD_SIZE}px`,
|
|
46
55
|
border: '2px solid transparent',
|
|
47
56
|
boxSizing: 'border-box',
|
|
48
57
|
borderRadius: '6px',
|
|
@@ -53,23 +62,40 @@ const sharedColorContainerStyles = css({
|
|
|
53
62
|
cursor: 'pointer',
|
|
54
63
|
outline: 'none'
|
|
55
64
|
});
|
|
65
|
+
const smallColorContainerSize = css({
|
|
66
|
+
width: '22px',
|
|
67
|
+
height: '22px',
|
|
68
|
+
top: "var(--ds-space-negative-025, -2px)"
|
|
69
|
+
});
|
|
70
|
+
const defaultColorContainerSize = css({
|
|
71
|
+
width: `${COLOR_CARD_SIZE}px`,
|
|
72
|
+
height: `${COLOR_CARD_SIZE}px`
|
|
73
|
+
});
|
|
56
74
|
const colorCardButtonStyles = css({
|
|
57
75
|
':hover': {
|
|
58
76
|
borderColor: `var(--ds-background-neutral-subtle, ${N0})`
|
|
59
77
|
},
|
|
60
78
|
':not(:focus):hover, :focus': {
|
|
61
|
-
borderColor: `var(--ds-border-focused, ${B100})
|
|
79
|
+
borderColor: `var(--ds-border-focused, ${B100})`,
|
|
80
|
+
outline: 'none'
|
|
62
81
|
}
|
|
63
82
|
});
|
|
64
83
|
const colorCardButtonFocusedStyles = css({
|
|
65
|
-
borderColor: `var(--ds-border-focused, ${B100})
|
|
84
|
+
borderColor: `var(--ds-border-focused, ${B100})`,
|
|
85
|
+
outline: 'none'
|
|
66
86
|
});
|
|
67
87
|
const colorCardContentStyles = css({
|
|
68
88
|
position: 'absolute',
|
|
69
89
|
top: '1px',
|
|
70
90
|
left: '1px',
|
|
71
|
-
width: "var(--ds-space-300, 24px)",
|
|
72
|
-
height: "var(--ds-space-300, 24px)",
|
|
73
91
|
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
74
92
|
boxShadow: `inset 0px 0px 0px 1px ${`var(--ds-background-inverse-subtle, ${DN600A})`}`
|
|
93
|
+
});
|
|
94
|
+
const smallColorCardContentSize = css({
|
|
95
|
+
width: "var(--ds-space-200, 16px)",
|
|
96
|
+
height: "var(--ds-space-200, 16px)"
|
|
97
|
+
});
|
|
98
|
+
const defaultColorCardContentSize = css({
|
|
99
|
+
width: "var(--ds-space-300, 24px)",
|
|
100
|
+
height: "var(--ds-space-300, 24px)"
|
|
75
101
|
});
|
package/dist/es2019/utils.js
CHANGED
|
@@ -4,19 +4,27 @@ import { gridSize } from '@atlaskit/theme';
|
|
|
4
4
|
import { COLOR_CARD_SIZE } from './constants';
|
|
5
5
|
import memoizeOne from 'memoize-one';
|
|
6
6
|
import { Mode } from './types';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
export const getWidth = (cols, mode) => {
|
|
8
9
|
const width = cols * (COLOR_CARD_SIZE + gridSize() / 2);
|
|
9
10
|
return mode === Mode.Standard ? width + gridSize() : width;
|
|
10
11
|
};
|
|
11
|
-
export const getOptions = memoizeOne((palette, selectedColor) => {
|
|
12
|
+
export const getOptions = memoizeOne((palette, selectedColor, showDefaultSwatchColor) => {
|
|
12
13
|
let focusedItemIndex = 0;
|
|
14
|
+
let defaultSelectedColor = palette[0];
|
|
15
|
+
if (getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') && !showDefaultSwatchColor) {
|
|
16
|
+
defaultSelectedColor = {
|
|
17
|
+
label: '',
|
|
18
|
+
value: ''
|
|
19
|
+
};
|
|
20
|
+
}
|
|
13
21
|
const value = palette.find((color, index) => {
|
|
14
22
|
if (color.value === selectedColor) {
|
|
15
23
|
focusedItemIndex = index;
|
|
16
24
|
return true;
|
|
17
25
|
}
|
|
18
26
|
return false;
|
|
19
|
-
}) ||
|
|
27
|
+
}) || defaultSelectedColor;
|
|
20
28
|
return {
|
|
21
29
|
options: palette,
|
|
22
30
|
value,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
/** @jsx jsx */
|
|
2
|
-
import React, { useCallback } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
3
4
|
import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
|
|
4
5
|
import Tooltip from '@atlaskit/tooltip';
|
|
5
6
|
import { COLOR_CARD_SIZE, KEY_ENTER, KEY_SPACE } from '../constants';
|
|
6
7
|
import { css, jsx } from '@emotion/react';
|
|
7
8
|
import { N0, DN600A, B75 } from '@atlaskit/theme/colors';
|
|
9
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
10
|
var ColorCard = function ColorCard(props) {
|
|
9
11
|
var value = props.value,
|
|
10
12
|
label = props.label,
|
|
@@ -15,6 +17,7 @@ var ColorCard = function ColorCard(props) {
|
|
|
15
17
|
isTabbing = props.isTabbing,
|
|
16
18
|
onClick = props.onClick,
|
|
17
19
|
onKeyDown = props.onKeyDown;
|
|
20
|
+
var ref = useRef(null);
|
|
18
21
|
var handleMouseDown = useCallback(function (event) {
|
|
19
22
|
event.preventDefault();
|
|
20
23
|
}, []);
|
|
@@ -34,9 +37,24 @@ var ColorCard = function ColorCard(props) {
|
|
|
34
37
|
onKeyDown(value);
|
|
35
38
|
}
|
|
36
39
|
}, [isTabbing, onKeyDown, value]);
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
if (getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy')) {
|
|
42
|
+
var refCurrent = ref.current;
|
|
43
|
+
var _handleKeyDown = function _handleKeyDown(e) {
|
|
44
|
+
if (e.key === 'Tab') {
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
refCurrent === null || refCurrent === void 0 || refCurrent.addEventListener('keydown', _handleKeyDown);
|
|
50
|
+
return function () {
|
|
51
|
+
refCurrent === null || refCurrent === void 0 || refCurrent.removeEventListener('keydown', _handleKeyDown);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}, []);
|
|
37
55
|
return jsx(Tooltip, {
|
|
38
56
|
content: label
|
|
39
|
-
}, jsx("div", {
|
|
57
|
+
}, jsx("div", _extends({
|
|
40
58
|
css: [sharedColorContainerStyles, (isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && !isTabbing && colorCardOptionFocusedStyles],
|
|
41
59
|
onClick: handleClick,
|
|
42
60
|
onMouseDown: handleMouseDown,
|
|
@@ -45,7 +63,9 @@ var ColorCard = function ColorCard(props) {
|
|
|
45
63
|
"aria-checked": selected,
|
|
46
64
|
"aria-label": label,
|
|
47
65
|
tabIndex: 0
|
|
48
|
-
},
|
|
66
|
+
}, getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') && {
|
|
67
|
+
ref: ref
|
|
68
|
+
}), jsx("div", {
|
|
49
69
|
css: colorCardContentStyles,
|
|
50
70
|
style: {
|
|
51
71
|
background: value || 'transparent'
|
|
@@ -91,5 +111,6 @@ var colorCardContentStyles = css({
|
|
|
91
111
|
boxShadow: "inset 0px 0px 0px 1px ".concat("var(--ds-background-inverse-subtle, ".concat(DN600A, ")"))
|
|
92
112
|
});
|
|
93
113
|
var colorCardContentCheckMarkStyles = css({
|
|
114
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
94
115
|
margin: '1px'
|
|
95
116
|
});
|
|
@@ -27,7 +27,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
27
27
|
attributes: {
|
|
28
28
|
componentName: 'color-picker',
|
|
29
29
|
packageName: "@atlaskit/color-picker",
|
|
30
|
-
packageVersion: "3.2.
|
|
30
|
+
packageVersion: "3.2.6"
|
|
31
31
|
}
|
|
32
32
|
})(createAnalyticsEvent);
|
|
33
33
|
}
|
|
@@ -69,7 +69,7 @@ export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAn
|
|
|
69
69
|
export default withAnalyticsContext({
|
|
70
70
|
componentName: 'color-picker',
|
|
71
71
|
packageName: "@atlaskit/color-picker",
|
|
72
|
-
packageVersion: "3.2.
|
|
72
|
+
packageVersion: "3.2.6"
|
|
73
73
|
})(withAnalyticsEvents()(ColorPaletteMenuWithoutAnalytics));
|
|
74
74
|
var colorCardWrapperStyles = css({
|
|
75
75
|
display: 'flex',
|
|
@@ -17,6 +17,7 @@ import { KEY_ARROW_DOWN, KEY_ARROW_UP, KEY_TAB } from '../constants';
|
|
|
17
17
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
18
18
|
import { getOptions } from '../utils';
|
|
19
19
|
import { css, jsx } from '@emotion/react';
|
|
20
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
20
21
|
var defaultPopperProps = {
|
|
21
22
|
strategy: 'fixed',
|
|
22
23
|
modifiers: [{
|
|
@@ -28,7 +29,7 @@ var defaultPopperProps = {
|
|
|
28
29
|
placement: 'bottom-start'
|
|
29
30
|
};
|
|
30
31
|
var packageName = "@atlaskit/color-picker";
|
|
31
|
-
var packageVersion = "3.2.
|
|
32
|
+
var packageVersion = "3.2.6";
|
|
32
33
|
export var ColorPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
33
34
|
_inherits(ColorPickerWithoutAnalytics, _React$Component);
|
|
34
35
|
var _super = _createSuper(ColorPickerWithoutAnalytics);
|
|
@@ -74,6 +75,8 @@ export var ColorPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component
|
|
|
74
75
|
_this.setState({
|
|
75
76
|
isTabbing: false
|
|
76
77
|
});
|
|
78
|
+
} else if (getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') && key === 'Escape') {
|
|
79
|
+
e.stopPropagation();
|
|
77
80
|
}
|
|
78
81
|
});
|
|
79
82
|
return _this;
|
|
@@ -89,11 +92,15 @@ export var ColorPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component
|
|
|
89
92
|
_this$props$popperPro = _this$props.popperProps,
|
|
90
93
|
popperProps = _this$props$popperPro === void 0 ? defaultPopperProps : _this$props$popperPro,
|
|
91
94
|
_this$props$label = _this$props.label,
|
|
92
|
-
label = _this$props$label === void 0 ? 'Color picker' : _this$props$label
|
|
93
|
-
|
|
95
|
+
label = _this$props$label === void 0 ? 'Color picker' : _this$props$label,
|
|
96
|
+
selectedColourSwatchSize = _this$props.selectedColourSwatchSize,
|
|
97
|
+
_this$props$showDefau = _this$props.showDefaultSwatchColor,
|
|
98
|
+
showDefaultSwatchColor = _this$props$showDefau === void 0 ? true : _this$props$showDefau,
|
|
99
|
+
isDisabledSelectedSwatch = _this$props.isDisabledSelectedSwatch;
|
|
100
|
+
var _getOptions = getOptions(palette, selectedColor, showDefaultSwatchColor),
|
|
94
101
|
options = _getOptions.options,
|
|
95
102
|
value = _getOptions.value;
|
|
96
|
-
var fullLabel = "".concat(label, ", ").concat(value.label, " selected");
|
|
103
|
+
var fullLabel = value.label && "".concat(label, ", ").concat(value.label, " selected");
|
|
97
104
|
return jsx(PopupSelect, {
|
|
98
105
|
target: function target(_ref) {
|
|
99
106
|
var ref = _ref.ref,
|
|
@@ -104,6 +111,9 @@ export var ColorPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component
|
|
|
104
111
|
}, jsx(Trigger, _extends({}, value, {
|
|
105
112
|
label: fullLabel,
|
|
106
113
|
expanded: isOpen
|
|
114
|
+
}, getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') && {
|
|
115
|
+
swatchSize: selectedColourSwatchSize,
|
|
116
|
+
isDisabled: isDisabledSelectedSwatch
|
|
107
117
|
})));
|
|
108
118
|
},
|
|
109
119
|
popperProps: popperProps,
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
/** @jsx jsx */
|
|
2
3
|
import { useCallback } from 'react';
|
|
3
4
|
import Tooltip from '@atlaskit/tooltip';
|
|
4
5
|
import { css, jsx } from '@emotion/react';
|
|
5
6
|
import { COLOR_CARD_SIZE } from '../constants';
|
|
6
7
|
import { B100, DN600A, N0 } from '@atlaskit/theme/colors';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
9
|
var ColorCard = function ColorCard(_ref) {
|
|
8
10
|
var value = _ref.value,
|
|
9
11
|
label = _ref.label,
|
|
10
12
|
expanded = _ref.expanded,
|
|
11
|
-
onClick = _ref.onClick
|
|
13
|
+
onClick = _ref.onClick,
|
|
14
|
+
_ref$swatchSize = _ref.swatchSize,
|
|
15
|
+
swatchSize = _ref$swatchSize === void 0 ? 'default' : _ref$swatchSize,
|
|
16
|
+
isDisabled = _ref.isDisabled;
|
|
12
17
|
var handleMouseDown = useCallback(function (event) {
|
|
13
18
|
event.preventDefault();
|
|
14
19
|
}, []);
|
|
@@ -21,27 +26,32 @@ var ColorCard = function ColorCard(_ref) {
|
|
|
21
26
|
}, [onClick]);
|
|
22
27
|
return jsx(Tooltip, {
|
|
23
28
|
content: label
|
|
24
|
-
}, jsx("button", {
|
|
25
|
-
css: [sharedColorContainerStyles, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
29
|
+
}, jsx("button", _extends({}, getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') ? {
|
|
30
|
+
css: [sharedColorContainerStyles, swatchSize === 'small' ? smallColorContainerSize : defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
31
|
+
disabled: isDisabled
|
|
32
|
+
} : {
|
|
33
|
+
css: [sharedColorContainerStyles, defaultColorContainerSize, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles]
|
|
34
|
+
}, {
|
|
26
35
|
onClick: handleClick,
|
|
27
36
|
onMouseDown: handleMouseDown,
|
|
28
37
|
"aria-label": label,
|
|
29
38
|
"aria-expanded": expanded,
|
|
30
39
|
"aria-haspopup": true,
|
|
31
40
|
type: "button"
|
|
32
|
-
}, jsx("span", {
|
|
33
|
-
css: colorCardContentStyles,
|
|
41
|
+
}), jsx("span", _extends({}, getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') ? {
|
|
42
|
+
css: [colorCardContentStyles, swatchSize === 'small' ? smallColorCardContentSize : defaultColorCardContentSize]
|
|
43
|
+
} : {
|
|
44
|
+
css: [colorCardContentStyles, defaultColorCardContentSize]
|
|
45
|
+
}, {
|
|
34
46
|
style: {
|
|
35
47
|
background: value || 'transparent'
|
|
36
48
|
}
|
|
37
|
-
})));
|
|
49
|
+
}))));
|
|
38
50
|
};
|
|
39
51
|
export default ColorCard;
|
|
40
52
|
var sharedColorContainerStyles = css({
|
|
41
53
|
display: 'inline-block',
|
|
42
54
|
position: 'relative',
|
|
43
|
-
width: "".concat(COLOR_CARD_SIZE, "px"),
|
|
44
|
-
height: "".concat(COLOR_CARD_SIZE, "px"),
|
|
45
55
|
border: '2px solid transparent',
|
|
46
56
|
boxSizing: 'border-box',
|
|
47
57
|
borderRadius: '6px',
|
|
@@ -52,23 +62,40 @@ var sharedColorContainerStyles = css({
|
|
|
52
62
|
cursor: 'pointer',
|
|
53
63
|
outline: 'none'
|
|
54
64
|
});
|
|
65
|
+
var smallColorContainerSize = css({
|
|
66
|
+
width: '22px',
|
|
67
|
+
height: '22px',
|
|
68
|
+
top: "var(--ds-space-negative-025, -2px)"
|
|
69
|
+
});
|
|
70
|
+
var defaultColorContainerSize = css({
|
|
71
|
+
width: "".concat(COLOR_CARD_SIZE, "px"),
|
|
72
|
+
height: "".concat(COLOR_CARD_SIZE, "px")
|
|
73
|
+
});
|
|
55
74
|
var colorCardButtonStyles = css({
|
|
56
75
|
':hover': {
|
|
57
76
|
borderColor: "var(--ds-background-neutral-subtle, ".concat(N0, ")")
|
|
58
77
|
},
|
|
59
78
|
':not(:focus):hover, :focus': {
|
|
60
|
-
borderColor: "var(--ds-border-focused, ".concat(B100, ")")
|
|
79
|
+
borderColor: "var(--ds-border-focused, ".concat(B100, ")"),
|
|
80
|
+
outline: 'none'
|
|
61
81
|
}
|
|
62
82
|
});
|
|
63
83
|
var colorCardButtonFocusedStyles = css({
|
|
64
|
-
borderColor: "var(--ds-border-focused, ".concat(B100, ")")
|
|
84
|
+
borderColor: "var(--ds-border-focused, ".concat(B100, ")"),
|
|
85
|
+
outline: 'none'
|
|
65
86
|
});
|
|
66
87
|
var colorCardContentStyles = css({
|
|
67
88
|
position: 'absolute',
|
|
68
89
|
top: '1px',
|
|
69
90
|
left: '1px',
|
|
70
|
-
width: "var(--ds-space-300, 24px)",
|
|
71
|
-
height: "var(--ds-space-300, 24px)",
|
|
72
91
|
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
73
92
|
boxShadow: "inset 0px 0px 0px 1px ".concat("var(--ds-background-inverse-subtle, ".concat(DN600A, ")"))
|
|
93
|
+
});
|
|
94
|
+
var smallColorCardContentSize = css({
|
|
95
|
+
width: "var(--ds-space-200, 16px)",
|
|
96
|
+
height: "var(--ds-space-200, 16px)"
|
|
97
|
+
});
|
|
98
|
+
var defaultColorCardContentSize = css({
|
|
99
|
+
width: "var(--ds-space-300, 24px)",
|
|
100
|
+
height: "var(--ds-space-300, 24px)"
|
|
74
101
|
});
|
package/dist/esm/utils.js
CHANGED
|
@@ -4,19 +4,27 @@ import { gridSize } from '@atlaskit/theme';
|
|
|
4
4
|
import { COLOR_CARD_SIZE } from './constants';
|
|
5
5
|
import memoizeOne from 'memoize-one';
|
|
6
6
|
import { Mode } from './types';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
export var getWidth = function getWidth(cols, mode) {
|
|
8
9
|
var width = cols * (COLOR_CARD_SIZE + gridSize() / 2);
|
|
9
10
|
return mode === Mode.Standard ? width + gridSize() : width;
|
|
10
11
|
};
|
|
11
|
-
export var getOptions = memoizeOne(function (palette, selectedColor) {
|
|
12
|
+
export var getOptions = memoizeOne(function (palette, selectedColor, showDefaultSwatchColor) {
|
|
12
13
|
var focusedItemIndex = 0;
|
|
14
|
+
var defaultSelectedColor = palette[0];
|
|
15
|
+
if (getBooleanFF('platform.color-picker-radio-button-functionality_6hkcy') && !showDefaultSwatchColor) {
|
|
16
|
+
defaultSelectedColor = {
|
|
17
|
+
label: '',
|
|
18
|
+
value: ''
|
|
19
|
+
};
|
|
20
|
+
}
|
|
13
21
|
var value = palette.find(function (color, index) {
|
|
14
22
|
if (color.value === selectedColor) {
|
|
15
23
|
focusedItemIndex = index;
|
|
16
24
|
return true;
|
|
17
25
|
}
|
|
18
26
|
return false;
|
|
19
|
-
}) ||
|
|
27
|
+
}) || defaultSelectedColor;
|
|
20
28
|
return {
|
|
21
29
|
options: palette,
|
|
22
30
|
value: value,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { PopupSelectProps, ValueType } from '@atlaskit/select';
|
|
4
|
-
import { Color, Palette } from '../types';
|
|
4
|
+
import { Color, Palette, SwatchSize } from '../types';
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
export interface Props {
|
|
7
7
|
/** color picker button label */
|
|
@@ -20,6 +20,12 @@ export interface Props {
|
|
|
20
20
|
onChange: (value: string, analyticsEvent?: object) => void;
|
|
21
21
|
/** You should not be accessing this prop under any circumstances. It is provided by @atlaskit/analytics-next. */
|
|
22
22
|
createAnalyticsEvent?: any;
|
|
23
|
+
/** swatch button size */
|
|
24
|
+
selectedColourSwatchSize?: SwatchSize;
|
|
25
|
+
/** swatch button default color */
|
|
26
|
+
showDefaultSwatchColor?: boolean;
|
|
27
|
+
/** diasble swatch button */
|
|
28
|
+
isDisabledSelectedSwatch?: boolean;
|
|
23
29
|
}
|
|
24
30
|
export declare class ColorPickerWithoutAnalytics extends React.Component<Props> {
|
|
25
31
|
createAndFireEventOnAtlaskit: (payload: import("@atlaskit/analytics-next").AnalyticsEventPayload) => (createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent) => import("@atlaskit/analytics-next").UIAnalyticsEvent;
|
|
@@ -32,5 +38,5 @@ export declare class ColorPickerWithoutAnalytics extends React.Component<Props>
|
|
|
32
38
|
onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
|
|
33
39
|
render(): jsx.JSX.Element;
|
|
34
40
|
}
|
|
35
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "label" | "analyticsContext" | "key" | "onChange" | "checkMarkColor" | "cols" | "popperProps" | "palette" | "selectedColor"> & React.RefAttributes<any>>;
|
|
41
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "label" | "analyticsContext" | "key" | "onChange" | "checkMarkColor" | "cols" | "popperProps" | "palette" | "selectedColor" | "selectedColourSwatchSize" | "showDefaultSwatchColor" | "isDisabledSelectedSwatch"> & React.RefAttributes<any>>;
|
|
36
42
|
export default _default;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
|
+
import { SwatchSize } from '../types';
|
|
2
3
|
export interface Props {
|
|
3
4
|
value: string;
|
|
4
5
|
label?: string;
|
|
5
6
|
onClick?: () => void;
|
|
6
7
|
expanded?: boolean;
|
|
8
|
+
swatchSize?: SwatchSize;
|
|
9
|
+
isDisabled?: boolean;
|
|
7
10
|
}
|
|
8
|
-
declare const ColorCard: ({ value, label, expanded, onClick }: Props) => jsx.JSX.Element;
|
|
11
|
+
declare const ColorCard: ({ value, label, expanded, onClick, swatchSize, isDisabled, }: Props) => jsx.JSX.Element;
|
|
9
12
|
export default ColorCard;
|
package/dist/types/types.d.ts
CHANGED
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mode, Palette } from './types';
|
|
2
2
|
export declare const getWidth: (cols: number, mode?: Mode) => number;
|
|
3
|
-
export declare const getOptions: import("memoize-one").MemoizedFn<(palette: Palette, selectedColor?: string) => {
|
|
3
|
+
export declare const getOptions: import("memoize-one").MemoizedFn<(palette: Palette, selectedColor?: string, showDefaultSwatchColor?: boolean) => {
|
|
4
4
|
options: Palette;
|
|
5
5
|
value: import("./types").Color;
|
|
6
6
|
focusedItemIndex: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { PopupSelectProps, ValueType } from '@atlaskit/select';
|
|
4
|
-
import { Color, Palette } from '../types';
|
|
4
|
+
import { Color, Palette, SwatchSize } from '../types';
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
export interface Props {
|
|
7
7
|
/** color picker button label */
|
|
@@ -20,6 +20,12 @@ export interface Props {
|
|
|
20
20
|
onChange: (value: string, analyticsEvent?: object) => void;
|
|
21
21
|
/** You should not be accessing this prop under any circumstances. It is provided by @atlaskit/analytics-next. */
|
|
22
22
|
createAnalyticsEvent?: any;
|
|
23
|
+
/** swatch button size */
|
|
24
|
+
selectedColourSwatchSize?: SwatchSize;
|
|
25
|
+
/** swatch button default color */
|
|
26
|
+
showDefaultSwatchColor?: boolean;
|
|
27
|
+
/** diasble swatch button */
|
|
28
|
+
isDisabledSelectedSwatch?: boolean;
|
|
23
29
|
}
|
|
24
30
|
export declare class ColorPickerWithoutAnalytics extends React.Component<Props> {
|
|
25
31
|
createAndFireEventOnAtlaskit: (payload: import("@atlaskit/analytics-next").AnalyticsEventPayload) => (createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent) => import("@atlaskit/analytics-next").UIAnalyticsEvent;
|
|
@@ -32,5 +38,5 @@ export declare class ColorPickerWithoutAnalytics extends React.Component<Props>
|
|
|
32
38
|
onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
|
|
33
39
|
render(): jsx.JSX.Element;
|
|
34
40
|
}
|
|
35
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "label" | "analyticsContext" | "key" | "onChange" | "checkMarkColor" | "cols" | "popperProps" | "palette" | "selectedColor"> & React.RefAttributes<any>>;
|
|
41
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "label" | "analyticsContext" | "key" | "onChange" | "checkMarkColor" | "cols" | "popperProps" | "palette" | "selectedColor" | "selectedColourSwatchSize" | "showDefaultSwatchColor" | "isDisabledSelectedSwatch"> & React.RefAttributes<any>>;
|
|
36
42
|
export default _default;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
|
+
import { SwatchSize } from '../types';
|
|
2
3
|
export interface Props {
|
|
3
4
|
value: string;
|
|
4
5
|
label?: string;
|
|
5
6
|
onClick?: () => void;
|
|
6
7
|
expanded?: boolean;
|
|
8
|
+
swatchSize?: SwatchSize;
|
|
9
|
+
isDisabled?: boolean;
|
|
7
10
|
}
|
|
8
|
-
declare const ColorCard: ({ value, label, expanded, onClick }: Props) => jsx.JSX.Element;
|
|
11
|
+
declare const ColorCard: ({ value, label, expanded, onClick, swatchSize, isDisabled, }: Props) => jsx.JSX.Element;
|
|
9
12
|
export default ColorCard;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mode, Palette } from './types';
|
|
2
2
|
export declare const getWidth: (cols: number, mode?: Mode) => number;
|
|
3
|
-
export declare const getOptions: import("memoize-one").MemoizedFn<(palette: Palette, selectedColor?: string) => {
|
|
3
|
+
export declare const getOptions: import("memoize-one").MemoizedFn<(palette: Palette, selectedColor?: string, showDefaultSwatchColor?: boolean) => {
|
|
4
4
|
options: Palette;
|
|
5
5
|
value: import("./types").Color;
|
|
6
6
|
focusedItemIndex: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/color-picker",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.6",
|
|
4
4
|
"description": "Jira Color Picker Component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
36
36
|
"@atlaskit/icon": "^22.1.0",
|
|
37
|
+
"@atlaskit/platform-feature-flags": "^0.2.5",
|
|
37
38
|
"@atlaskit/select": "^17.3.0",
|
|
38
39
|
"@atlaskit/theme": "^12.6.0",
|
|
39
40
|
"@atlaskit/tokens": "^1.42.0",
|
|
@@ -73,5 +74,10 @@
|
|
|
73
74
|
]
|
|
74
75
|
}
|
|
75
76
|
},
|
|
76
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
77
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
|
|
78
|
+
"platform-feature-flags": {
|
|
79
|
+
"platform.color-picker-radio-button-functionality_6hkcy": {
|
|
80
|
+
"type": "boolean"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
77
83
|
}
|