@atlaskit/color-picker 3.1.9 → 3.2.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 +6 -0
- package/dist/cjs/components/ColorCard.js +88 -80
- package/dist/cjs/components/ColorPaletteMenu.js +88 -88
- package/dist/cjs/components/ColorPicker.js +12 -8
- package/dist/cjs/components/Trigger.js +72 -56
- package/dist/cjs/components/components.js +35 -27
- package/dist/cjs/utils.js +4 -2
- package/dist/es2019/components/ColorCard.js +93 -70
- package/dist/es2019/components/ColorPaletteMenu.js +89 -73
- package/dist/es2019/components/ColorPicker.js +14 -9
- package/dist/es2019/components/Trigger.js +72 -39
- package/dist/es2019/components/components.js +32 -22
- package/dist/es2019/utils.js +5 -1
- package/dist/esm/components/ColorCard.js +89 -85
- package/dist/esm/components/ColorPaletteMenu.js +89 -90
- package/dist/esm/components/ColorPicker.js +14 -9
- package/dist/esm/components/Trigger.js +71 -57
- package/dist/esm/components/components.js +35 -27
- package/dist/esm/utils.js +4 -2
- package/dist/types/components/ColorCard.d.ts +3 -9
- package/dist/types/components/ColorPaletteMenu.d.ts +8 -18
- package/dist/types/components/ColorPicker.d.ts +6 -4
- package/dist/types/components/Trigger.d.ts +3 -6
- package/dist/types/components/components.d.ts +4 -3
- package/dist/types/utils.d.ts +2 -2
- package/dist/types-ts4.5/components/ColorCard.d.ts +3 -9
- package/dist/types-ts4.5/components/ColorPaletteMenu.d.ts +8 -18
- package/dist/types-ts4.5/components/ColorPicker.d.ts +6 -4
- package/dist/types-ts4.5/components/Trigger.d.ts +3 -6
- package/dist/types-ts4.5/components/components.d.ts +4 -3
- package/dist/types-ts4.5/utils.d.ts +2 -2
- package/package.json +4 -4
- package/dist/cjs/styled/ColorCard.js +0 -40
- package/dist/cjs/styled/ColorPalette.js +0 -24
- package/dist/cjs/styled/ColorPicker.js +0 -11
- package/dist/es2019/styled/ColorCard.js +0 -72
- package/dist/es2019/styled/ColorPalette.js +0 -28
- package/dist/es2019/styled/ColorPicker.js +0 -4
- package/dist/esm/styled/ColorCard.js +0 -30
- package/dist/esm/styled/ColorPalette.js +0 -18
- package/dist/esm/styled/ColorPicker.js +0 -4
- package/dist/types/styled/ColorCard.d.ts +0 -13
- package/dist/types/styled/ColorPalette.d.ts +0 -13
- package/dist/types/styled/ColorPicker.d.ts +0 -2
- package/dist/types-ts4.5/styled/ColorCard.d.ts +0 -13
- package/dist/types-ts4.5/styled/ColorPalette.d.ts +0 -13
- package/dist/types-ts4.5/styled/ColorPicker.d.ts +0 -2
- package/tmp/api-report-tmp.d.ts +0 -114
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
|
|
3
4
|
import ColorCard from './ColorCard';
|
|
4
5
|
import { getWidth } from '../utils';
|
|
5
|
-
import {
|
|
6
|
+
import { COLOR_CARD_SIZE } from '../constants';
|
|
7
|
+
import { css, jsx } from '@emotion/react';
|
|
6
8
|
export const MenuList = props => {
|
|
7
9
|
const {
|
|
8
|
-
cx,
|
|
9
10
|
selectProps: {
|
|
10
11
|
cols
|
|
11
12
|
},
|
|
12
13
|
innerRef,
|
|
13
|
-
|
|
14
|
+
children
|
|
14
15
|
} = props;
|
|
15
|
-
return
|
|
16
|
+
return jsx("div", {
|
|
17
|
+
css: colorPaletteContainerStyles,
|
|
16
18
|
role: "radiogroup",
|
|
17
19
|
style: {
|
|
18
20
|
maxWidth: cols ? getWidth(cols) : undefined
|
|
19
21
|
},
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
+
ref: innerRef
|
|
23
|
+
}, children);
|
|
22
24
|
};
|
|
23
25
|
export const Option = props => {
|
|
24
26
|
const {
|
|
@@ -35,20 +37,28 @@ export const Option = props => {
|
|
|
35
37
|
isSelected,
|
|
36
38
|
innerProps
|
|
37
39
|
} = props;
|
|
38
|
-
return (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}))
|
|
51
|
-
);
|
|
40
|
+
return jsx("div", _extends({
|
|
41
|
+
css: colorCardWrapperStyles
|
|
42
|
+
}, innerProps), jsx(ColorCard, {
|
|
43
|
+
label: label,
|
|
44
|
+
value: value,
|
|
45
|
+
checkMarkColor: checkMarkColor,
|
|
46
|
+
isOption: true,
|
|
47
|
+
focused: isFocused,
|
|
48
|
+
selected: isSelected,
|
|
49
|
+
onKeyDown: value => onOptionKeyDown(value),
|
|
50
|
+
isTabbing: isTabbing
|
|
51
|
+
}));
|
|
52
52
|
};
|
|
53
53
|
export const DropdownIndicator = () => null;
|
|
54
|
-
export const Placeholder = () => null;
|
|
54
|
+
export const Placeholder = () => null;
|
|
55
|
+
const colorCardWrapperStyles = css({
|
|
56
|
+
display: 'flex',
|
|
57
|
+
margin: "var(--ds-space-025, 2px)",
|
|
58
|
+
height: `${COLOR_CARD_SIZE}px`
|
|
59
|
+
});
|
|
60
|
+
const colorPaletteContainerStyles = css({
|
|
61
|
+
display: 'flex',
|
|
62
|
+
flexWrap: 'wrap',
|
|
63
|
+
padding: "var(--ds-space-050, 4px)"
|
|
64
|
+
});
|
package/dist/es2019/utils.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
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
|
+
export const getWidth = (cols, mode) => {
|
|
8
|
+
const width = cols * (COLOR_CARD_SIZE + gridSize() / 2);
|
|
9
|
+
return mode === Mode.Standard ? width + gridSize() : width;
|
|
10
|
+
};
|
|
7
11
|
export const getOptions = memoizeOne((palette, selectedColor) => {
|
|
8
12
|
let focusedItemIndex = 0;
|
|
9
13
|
const value = palette.find((color, index) => {
|
|
@@ -1,91 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import { PureComponent } from 'react';
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
12
3
|
import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
|
|
13
|
-
// AFP-2532 TODO: Fix automatic suppressions below
|
|
14
|
-
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
15
|
-
import { colors } from '@atlaskit/theme';
|
|
16
4
|
import Tooltip from '@atlaskit/tooltip';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
import { COLOR_CARD_SIZE, KEY_ENTER, KEY_SPACE } from '../constants';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { N0, DN600A, B75 } from '@atlaskit/theme/colors';
|
|
8
|
+
var ColorCard = function ColorCard(props) {
|
|
9
|
+
var value = props.value,
|
|
10
|
+
label = props.label,
|
|
11
|
+
selected = props.selected,
|
|
12
|
+
focused = props.focused,
|
|
13
|
+
_props$checkMarkColor = props.checkMarkColor,
|
|
14
|
+
checkMarkColor = _props$checkMarkColor === void 0 ? "var(--ds-icon-inverse, ".concat(N0, ")") : _props$checkMarkColor,
|
|
15
|
+
isTabbing = props.isTabbing,
|
|
16
|
+
onClick = props.onClick,
|
|
17
|
+
onKeyDown = props.onKeyDown;
|
|
18
|
+
var handleMouseDown = useCallback(function (event) {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
}, []);
|
|
21
|
+
var handleClick = useCallback(function (event) {
|
|
22
|
+
if (onClick) {
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
onClick(value);
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
}, [onClick, value]);
|
|
27
|
+
var handleKeyDown = useCallback(function (event) {
|
|
28
|
+
var key = event.key;
|
|
29
|
+
if ((isTabbing === undefined || isTabbing) && onKeyDown && (key === KEY_ENTER || key === KEY_SPACE)) {
|
|
30
30
|
event.preventDefault();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var _this$props = _this.props,
|
|
34
|
-
onClick = _this$props.onClick,
|
|
35
|
-
value = _this$props.value;
|
|
36
|
-
if (onClick) {
|
|
37
|
-
event.preventDefault();
|
|
38
|
-
onClick(value);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
|
|
42
|
-
var key = event.key;
|
|
43
|
-
var _this$props2 = _this.props,
|
|
44
|
-
onKeyDown = _this$props2.onKeyDown,
|
|
45
|
-
value = _this$props2.value,
|
|
46
|
-
isTabbing = _this$props2.isTabbing;
|
|
47
|
-
if ((isTabbing === undefined || isTabbing) && onKeyDown && (key === KEY_ENTER || key === KEY_SPACE)) {
|
|
48
|
-
event.preventDefault();
|
|
49
|
-
if (isTabbing) {
|
|
50
|
-
event.stopPropagation();
|
|
51
|
-
}
|
|
52
|
-
onKeyDown(value);
|
|
31
|
+
if (isTabbing) {
|
|
32
|
+
event.stopPropagation();
|
|
53
33
|
}
|
|
54
|
-
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "ref", /*#__PURE__*/React.createRef());
|
|
56
|
-
return _this;
|
|
57
|
-
}
|
|
58
|
-
_createClass(ColorCard, [{
|
|
59
|
-
key: "render",
|
|
60
|
-
value: function render() {
|
|
61
|
-
var _this$props3 = this.props,
|
|
62
|
-
value = _this$props3.value,
|
|
63
|
-
label = _this$props3.label,
|
|
64
|
-
selected = _this$props3.selected,
|
|
65
|
-
focused = _this$props3.focused,
|
|
66
|
-
_this$props3$checkMar = _this$props3.checkMarkColor,
|
|
67
|
-
checkMarkColor = _this$props3$checkMar === void 0 ? colors.N0 : _this$props3$checkMar,
|
|
68
|
-
isTabbing = _this$props3.isTabbing;
|
|
69
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
70
|
-
content: label
|
|
71
|
-
}, /*#__PURE__*/React.createElement(ColorCardOption, {
|
|
72
|
-
onClick: this.onClick,
|
|
73
|
-
onMouseDown: this.onMouseDown,
|
|
74
|
-
focused: focused,
|
|
75
|
-
role: "radio",
|
|
76
|
-
"aria-checked": selected,
|
|
77
|
-
"aria-label": label,
|
|
78
|
-
tabIndex: 0,
|
|
79
|
-
onKeyDown: this.onKeyDown,
|
|
80
|
-
isTabbing: isTabbing
|
|
81
|
-
}, /*#__PURE__*/React.createElement(ColorCardContent, {
|
|
82
|
-
color: value || 'transparent'
|
|
83
|
-
}, selected && /*#__PURE__*/React.createElement(ColorCardContentCheckMark, null, /*#__PURE__*/React.createElement(EditorDoneIcon, {
|
|
84
|
-
primaryColor: checkMarkColor,
|
|
85
|
-
label: ""
|
|
86
|
-
})))));
|
|
34
|
+
onKeyDown(value);
|
|
87
35
|
}
|
|
88
|
-
}]);
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
36
|
+
}, [isTabbing, onKeyDown, value]);
|
|
37
|
+
return jsx(Tooltip, {
|
|
38
|
+
content: label
|
|
39
|
+
}, jsx("div", {
|
|
40
|
+
css: [sharedColorContainerStyles, (isTabbing === undefined || isTabbing) && colorCardOptionTabbingStyles, focused && !isTabbing && colorCardOptionFocusedStyles],
|
|
41
|
+
onClick: handleClick,
|
|
42
|
+
onMouseDown: handleMouseDown,
|
|
43
|
+
onKeyDown: handleKeyDown,
|
|
44
|
+
role: "radio",
|
|
45
|
+
"aria-checked": selected,
|
|
46
|
+
"aria-label": label,
|
|
47
|
+
tabIndex: 0
|
|
48
|
+
}, jsx("div", {
|
|
49
|
+
css: colorCardContentStyles,
|
|
50
|
+
style: {
|
|
51
|
+
background: value || 'transparent'
|
|
52
|
+
}
|
|
53
|
+
}, selected && jsx("div", {
|
|
54
|
+
css: colorCardContentCheckMarkStyles
|
|
55
|
+
}, jsx(EditorDoneIcon, {
|
|
56
|
+
primaryColor: checkMarkColor,
|
|
57
|
+
label: ""
|
|
58
|
+
})))));
|
|
59
|
+
};
|
|
60
|
+
export default ColorCard;
|
|
61
|
+
var sharedColorContainerStyles = css({
|
|
62
|
+
display: 'inline-block',
|
|
63
|
+
position: 'relative',
|
|
64
|
+
width: "".concat(COLOR_CARD_SIZE, "px"),
|
|
65
|
+
height: "".concat(COLOR_CARD_SIZE, "px"),
|
|
66
|
+
border: '2px solid transparent',
|
|
67
|
+
boxSizing: 'border-box',
|
|
68
|
+
borderRadius: '6px',
|
|
69
|
+
transition: 'border-color 0.15s cubic-bezier(0.47, 0.03, 0.49, 1.38)',
|
|
70
|
+
backgroundColor: "var(--ds-background-neutral-subtle, ".concat(N0, ")"),
|
|
71
|
+
borderColor: "var(--ds-background-neutral-subtle, ".concat(N0, ")"),
|
|
72
|
+
padding: "var(--ds-space-0, 0px)",
|
|
73
|
+
cursor: 'pointer',
|
|
74
|
+
outline: 'none'
|
|
75
|
+
});
|
|
76
|
+
var colorCardOptionTabbingStyles = css({
|
|
77
|
+
':hover, :focus': {
|
|
78
|
+
borderColor: "var(--ds-border-focused, ".concat(B75, ")")
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
var colorCardOptionFocusedStyles = css({
|
|
82
|
+
borderColor: "var(--ds-border-focused, ".concat(B75, ")")
|
|
83
|
+
});
|
|
84
|
+
var colorCardContentStyles = css({
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
top: '1px',
|
|
87
|
+
left: '1px',
|
|
88
|
+
width: "var(--ds-space-300, 24px)",
|
|
89
|
+
height: "var(--ds-space-300, 24px)",
|
|
90
|
+
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
91
|
+
boxShadow: "inset 0px 0px 0px 1px ".concat("var(--ds-background-inverse-subtle, ".concat(DN600A, ")"))
|
|
92
|
+
});
|
|
93
|
+
var colorCardContentCheckMarkStyles = css({
|
|
94
|
+
margin: '1px'
|
|
95
|
+
});
|
|
@@ -1,97 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
import React from 'react';
|
|
1
|
+
/** @jsx jsx */
|
|
11
2
|
import { Mode } from '../types';
|
|
12
|
-
import {
|
|
13
|
-
import { ColorCardWrapper, ColorPaletteMenu, ColorPaletteContainer } from '../styled/ColorPalette';
|
|
3
|
+
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
14
4
|
import ColorCard from './ColorCard';
|
|
15
|
-
import { getOptions } from '../utils';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
import { getOptions, getWidth } from '../utils';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { COLOR_CARD_SIZE } from '../constants';
|
|
8
|
+
import { N0, N40 } from '@atlaskit/theme/colors';
|
|
9
|
+
export var ColorPaletteMenuWithoutAnalytics = function ColorPaletteMenuWithoutAnalytics(_ref) {
|
|
10
|
+
var createAnalyticsEvent = _ref.createAnalyticsEvent,
|
|
11
|
+
onChange = _ref.onChange,
|
|
12
|
+
palette = _ref.palette,
|
|
13
|
+
selectedColor = _ref.selectedColor,
|
|
14
|
+
checkMarkColor = _ref.checkMarkColor,
|
|
15
|
+
_ref$label = _ref.label,
|
|
16
|
+
label = _ref$label === void 0 ? 'Color picker' : _ref$label,
|
|
17
|
+
_ref$cols = _ref.cols,
|
|
18
|
+
cols = _ref$cols === void 0 ? 6 : _ref$cols,
|
|
19
|
+
_ref$mode = _ref.mode,
|
|
20
|
+
mode = _ref$mode === void 0 ? Mode.Standard : _ref$mode;
|
|
21
|
+
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
22
|
+
var changeAnalyticsCaller = function changeAnalyticsCaller() {
|
|
23
|
+
if (createAnalyticsEvent) {
|
|
24
|
+
return createAndFireEventOnAtlaskit({
|
|
25
|
+
action: 'clicked',
|
|
26
|
+
actionSubject: 'color-palette-menu',
|
|
27
|
+
attributes: {
|
|
28
|
+
componentName: 'color-picker',
|
|
29
|
+
packageName: "@atlaskit/color-picker",
|
|
30
|
+
packageVersion: "3.2.0"
|
|
31
|
+
}
|
|
32
|
+
})(createAnalyticsEvent);
|
|
24
33
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return undefined;
|
|
41
|
-
});
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "onChange", function (value) {
|
|
43
|
-
_this.props.onChange(value, _this.changeAnalyticsCaller());
|
|
44
|
-
});
|
|
45
|
-
return _this;
|
|
46
|
-
}
|
|
47
|
-
_createClass(ColorPaletteMenuWithoutAnalytics, [{
|
|
48
|
-
key: "render",
|
|
49
|
-
value: function render() {
|
|
50
|
-
var _this2 = this;
|
|
51
|
-
var _this$props = this.props,
|
|
52
|
-
palette = _this$props.palette,
|
|
53
|
-
selectedColor = _this$props.selectedColor,
|
|
54
|
-
checkMarkColor = _this$props.checkMarkColor,
|
|
55
|
-
cols = _this$props.cols,
|
|
56
|
-
_this$props$label = _this$props.label,
|
|
57
|
-
label = _this$props$label === void 0 ? 'Color picker' : _this$props$label,
|
|
58
|
-
mode = _this$props.mode;
|
|
59
|
-
var _getOptions = getOptions(palette, selectedColor),
|
|
60
|
-
options = _getOptions.options,
|
|
61
|
-
selectedValue = _getOptions.value;
|
|
62
|
-
var fullLabel = "".concat(label, ", ").concat(selectedValue.label, " selected");
|
|
63
|
-
return /*#__PURE__*/React.createElement(ColorPaletteMenu, {
|
|
64
|
-
cols: cols,
|
|
65
|
-
"aria-label": fullLabel,
|
|
66
|
-
mode: mode,
|
|
67
|
-
role: "radiogroup"
|
|
68
|
-
}, /*#__PURE__*/React.createElement(ColorPaletteContainer, {
|
|
69
|
-
mode: mode
|
|
70
|
-
}, options.map(function (_ref) {
|
|
71
|
-
var label = _ref.label,
|
|
72
|
-
value = _ref.value;
|
|
73
|
-
return /*#__PURE__*/React.createElement(ColorCardWrapper, {
|
|
74
|
-
key: value
|
|
75
|
-
}, /*#__PURE__*/React.createElement(ColorCard, {
|
|
76
|
-
label: label,
|
|
77
|
-
value: value,
|
|
78
|
-
checkMarkColor: checkMarkColor,
|
|
79
|
-
isOption: true,
|
|
80
|
-
selected: value === selectedValue.value,
|
|
81
|
-
onClick: _this2.onChange,
|
|
82
|
-
onKeyDown: _this2.onChange
|
|
83
|
-
}));
|
|
84
|
-
})));
|
|
34
|
+
return undefined;
|
|
35
|
+
};
|
|
36
|
+
var handleChange = function handleChange(value) {
|
|
37
|
+
onChange(value, changeAnalyticsCaller());
|
|
38
|
+
};
|
|
39
|
+
var _getOptions = getOptions(palette, selectedColor),
|
|
40
|
+
options = _getOptions.options,
|
|
41
|
+
selectedValue = _getOptions.value;
|
|
42
|
+
var fullLabel = "".concat(label, ", ").concat(selectedValue.label, " selected");
|
|
43
|
+
return jsx("div", {
|
|
44
|
+
"aria-label": fullLabel,
|
|
45
|
+
role: "radiogroup",
|
|
46
|
+
css: [colorPaletteMenuStyles, mode === Mode.Standard && colorPaletteMenuStandardStyles],
|
|
47
|
+
style: {
|
|
48
|
+
width: "".concat(getWidth(cols, mode), "px")
|
|
85
49
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
50
|
+
}, jsx("div", {
|
|
51
|
+
css: [colorPaletteContainerStyles, mode === Mode.Compact && colorPaletteContainerCompactStyles]
|
|
52
|
+
}, options.map(function (_ref2) {
|
|
53
|
+
var label = _ref2.label,
|
|
54
|
+
value = _ref2.value;
|
|
55
|
+
return jsx("div", {
|
|
56
|
+
css: colorCardWrapperStyles,
|
|
57
|
+
key: value
|
|
58
|
+
}, jsx(ColorCard, {
|
|
59
|
+
label: label,
|
|
60
|
+
value: value,
|
|
61
|
+
checkMarkColor: checkMarkColor,
|
|
62
|
+
isOption: true,
|
|
63
|
+
selected: value === selectedValue.value,
|
|
64
|
+
onClick: handleChange,
|
|
65
|
+
onKeyDown: handleChange
|
|
66
|
+
}));
|
|
67
|
+
})));
|
|
68
|
+
};
|
|
93
69
|
export default withAnalyticsContext({
|
|
94
70
|
componentName: 'color-picker',
|
|
95
71
|
packageName: "@atlaskit/color-picker",
|
|
96
|
-
packageVersion: "3.
|
|
97
|
-
})(withAnalyticsEvents()(ColorPaletteMenuWithoutAnalytics));
|
|
72
|
+
packageVersion: "3.2.0"
|
|
73
|
+
})(withAnalyticsEvents()(ColorPaletteMenuWithoutAnalytics));
|
|
74
|
+
var colorCardWrapperStyles = css({
|
|
75
|
+
display: 'flex',
|
|
76
|
+
margin: "var(--ds-space-025, 2px)",
|
|
77
|
+
height: "".concat(COLOR_CARD_SIZE, "px")
|
|
78
|
+
});
|
|
79
|
+
var colorPaletteContainerStyles = css({
|
|
80
|
+
display: 'flex',
|
|
81
|
+
flexWrap: 'wrap',
|
|
82
|
+
padding: "var(--ds-space-050, 4px)"
|
|
83
|
+
});
|
|
84
|
+
var colorPaletteContainerCompactStyles = css({
|
|
85
|
+
padding: "var(--ds-space-0, 0)"
|
|
86
|
+
});
|
|
87
|
+
var colorPaletteMenuStyles = css({
|
|
88
|
+
display: 'flex',
|
|
89
|
+
position: 'relative',
|
|
90
|
+
margin: "var(--ds-space-0, 0)",
|
|
91
|
+
backgroundColor: "var(--ds-surface-overlay, ".concat(N0, ")")
|
|
92
|
+
});
|
|
93
|
+
var colorPaletteMenuStandardStyles = css({
|
|
94
|
+
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
95
|
+
boxShadow: "var(--ds-shadow-overlay, ".concat("0 0 0 1px ".concat(N40, ", 0 0 8px ").concat(N40), ")")
|
|
96
|
+
});
|
|
@@ -8,14 +8,15 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
/** @jsx jsx */
|
|
11
12
|
import React from 'react';
|
|
12
13
|
import { PopupSelect } from '@atlaskit/select';
|
|
13
14
|
import Trigger from './Trigger';
|
|
14
15
|
import * as components from './components';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { ColorCardWrapper } from '../styled/ColorPicker';
|
|
16
|
+
import { KEY_ARROW_DOWN, KEY_ARROW_UP, KEY_TAB } from '../constants';
|
|
17
|
+
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
18
18
|
import { getOptions } from '../utils';
|
|
19
|
+
import { css, jsx } from '@emotion/react';
|
|
19
20
|
var defaultPopperProps = {
|
|
20
21
|
strategy: 'fixed',
|
|
21
22
|
modifiers: [{
|
|
@@ -27,7 +28,7 @@ var defaultPopperProps = {
|
|
|
27
28
|
placement: 'bottom-start'
|
|
28
29
|
};
|
|
29
30
|
var packageName = "@atlaskit/color-picker";
|
|
30
|
-
var packageVersion = "3.
|
|
31
|
+
var packageVersion = "3.2.0";
|
|
31
32
|
export var ColorPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
32
33
|
_inherits(ColorPickerWithoutAnalytics, _React$Component);
|
|
33
34
|
var _super = _createSuper(ColorPickerWithoutAnalytics);
|
|
@@ -93,13 +94,14 @@ export var ColorPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component
|
|
|
93
94
|
options = _getOptions.options,
|
|
94
95
|
value = _getOptions.value;
|
|
95
96
|
var fullLabel = "".concat(label, ", ").concat(value.label, " selected");
|
|
96
|
-
return
|
|
97
|
+
return jsx(PopupSelect, {
|
|
97
98
|
target: function target(_ref) {
|
|
98
99
|
var ref = _ref.ref,
|
|
99
100
|
isOpen = _ref.isOpen;
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
return jsx("div", {
|
|
102
|
+
css: colorCardWrapperStyles,
|
|
103
|
+
ref: ref
|
|
104
|
+
}, jsx(Trigger, _extends({}, value, {
|
|
103
105
|
label: fullLabel,
|
|
104
106
|
expanded: isOpen
|
|
105
107
|
})));
|
|
@@ -131,4 +133,7 @@ export default withAnalyticsContext({
|
|
|
131
133
|
componentName: 'color-picker',
|
|
132
134
|
packageName: packageName,
|
|
133
135
|
packageVersion: packageVersion
|
|
134
|
-
})(withAnalyticsEvents()(ColorPickerWithoutAnalytics));
|
|
136
|
+
})(withAnalyticsEvents()(ColorPickerWithoutAnalytics));
|
|
137
|
+
var colorCardWrapperStyles = css({
|
|
138
|
+
display: 'inline-block'
|
|
139
|
+
});
|
|
@@ -1,60 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import { ColorCardButton, ColorCardContent } from '../styled/ColorCard';
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { useCallback } from 'react';
|
|
12
3
|
import Tooltip from '@atlaskit/tooltip';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import { COLOR_CARD_SIZE } from '../constants';
|
|
6
|
+
import { B100, DN600A, N0 } from '@atlaskit/theme/colors';
|
|
7
|
+
var ColorCard = function ColorCard(_ref) {
|
|
8
|
+
var value = _ref.value,
|
|
9
|
+
label = _ref.label,
|
|
10
|
+
expanded = _ref.expanded,
|
|
11
|
+
onClick = _ref.onClick;
|
|
12
|
+
var handleMouseDown = useCallback(function (event) {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
}, []);
|
|
15
|
+
var handleClick = useCallback(function (event) {
|
|
16
|
+
event.currentTarget.focus();
|
|
17
|
+
if (onClick) {
|
|
24
18
|
event.preventDefault();
|
|
25
|
-
|
|
26
|
-
_defineProperty(_assertThisInitialized(_this), "onClick", function (event) {
|
|
27
|
-
var onClick = _this.props.onClick;
|
|
28
|
-
event.currentTarget.focus();
|
|
29
|
-
if (onClick) {
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
onClick();
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return _this;
|
|
35
|
-
}
|
|
36
|
-
_createClass(ColorCard, [{
|
|
37
|
-
key: "render",
|
|
38
|
-
value: function render() {
|
|
39
|
-
var _this$props = this.props,
|
|
40
|
-
value = _this$props.value,
|
|
41
|
-
label = _this$props.label,
|
|
42
|
-
expanded = _this$props.expanded;
|
|
43
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
44
|
-
content: label
|
|
45
|
-
}, /*#__PURE__*/React.createElement(ColorCardButton, {
|
|
46
|
-
onClick: this.onClick,
|
|
47
|
-
onMouseDown: this.onMouseDown,
|
|
48
|
-
focused: expanded,
|
|
49
|
-
"aria-label": label,
|
|
50
|
-
"aria-expanded": expanded,
|
|
51
|
-
"aria-haspopup": true,
|
|
52
|
-
type: "button"
|
|
53
|
-
}, /*#__PURE__*/React.createElement(ColorCardContent, {
|
|
54
|
-
color: value || 'transparent'
|
|
55
|
-
})));
|
|
19
|
+
onClick();
|
|
56
20
|
}
|
|
57
|
-
}]);
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
21
|
+
}, [onClick]);
|
|
22
|
+
return jsx(Tooltip, {
|
|
23
|
+
content: label
|
|
24
|
+
}, jsx("button", {
|
|
25
|
+
css: [sharedColorContainerStyles, colorCardButtonStyles, expanded && colorCardButtonFocusedStyles],
|
|
26
|
+
onClick: handleClick,
|
|
27
|
+
onMouseDown: handleMouseDown,
|
|
28
|
+
"aria-label": label,
|
|
29
|
+
"aria-expanded": expanded,
|
|
30
|
+
"aria-haspopup": true,
|
|
31
|
+
type: "button"
|
|
32
|
+
}, jsx("span", {
|
|
33
|
+
css: colorCardContentStyles,
|
|
34
|
+
style: {
|
|
35
|
+
background: value || 'transparent'
|
|
36
|
+
}
|
|
37
|
+
})));
|
|
38
|
+
};
|
|
39
|
+
export default ColorCard;
|
|
40
|
+
var sharedColorContainerStyles = css({
|
|
41
|
+
display: 'inline-block',
|
|
42
|
+
position: 'relative',
|
|
43
|
+
width: "".concat(COLOR_CARD_SIZE, "px"),
|
|
44
|
+
height: "".concat(COLOR_CARD_SIZE, "px"),
|
|
45
|
+
border: '2px solid transparent',
|
|
46
|
+
boxSizing: 'border-box',
|
|
47
|
+
borderRadius: '6px',
|
|
48
|
+
transition: 'border-color 0.15s cubic-bezier(0.47, 0.03, 0.49, 1.38)',
|
|
49
|
+
backgroundColor: "var(--ds-background-neutral-subtle, ".concat(N0, ")"),
|
|
50
|
+
borderColor: "var(--ds-background-neutral-subtle, ".concat(N0, ")"),
|
|
51
|
+
padding: "var(--ds-space-0, 0px)",
|
|
52
|
+
cursor: 'pointer',
|
|
53
|
+
outline: 'none'
|
|
54
|
+
});
|
|
55
|
+
var colorCardButtonStyles = css({
|
|
56
|
+
':hover': {
|
|
57
|
+
borderColor: "var(--ds-background-neutral-subtle, ".concat(N0, ")")
|
|
58
|
+
},
|
|
59
|
+
':not(:focus):hover, :focus': {
|
|
60
|
+
borderColor: "var(--ds-border-focused, ".concat(B100, ")")
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
var colorCardButtonFocusedStyles = css({
|
|
64
|
+
borderColor: "var(--ds-border-focused, ".concat(B100, ")")
|
|
65
|
+
});
|
|
66
|
+
var colorCardContentStyles = css({
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
top: '1px',
|
|
69
|
+
left: '1px',
|
|
70
|
+
width: "var(--ds-space-300, 24px)",
|
|
71
|
+
height: "var(--ds-space-300, 24px)",
|
|
72
|
+
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
73
|
+
boxShadow: "inset 0px 0px 0px 1px ".concat("var(--ds-background-inverse-subtle, ".concat(DN600A, ")"))
|
|
74
|
+
});
|