@atlaskit/editor-core 187.45.3 → 187.46.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 +10 -0
- package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/index.js +2 -2
- package/dist/cjs/plugins/find-replace/ui/FindReplaceToolbarButton.js +4 -5
- package/dist/cjs/plugins/floating-toolbar/index.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -1
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +4 -5
- package/dist/cjs/plugins/panel/toolbar.js +2 -2
- package/dist/cjs/plugins/text-color/pm-plugins/main.js +3 -4
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +6 -7
- package/dist/cjs/ui/Dropdown/index.js +1 -25
- package/dist/cjs/utils/index.js +12 -10
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/index.js +1 -1
- package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +3 -4
- package/dist/es2019/plugins/floating-toolbar/index.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -2
- package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +2 -2
- package/dist/es2019/plugins/panel/toolbar.js +1 -1
- package/dist/es2019/plugins/text-color/pm-plugins/main.js +2 -2
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +3 -3
- package/dist/es2019/ui/Dropdown/index.js +1 -19
- package/dist/es2019/utils/index.js +1 -9
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/alignment/ui/ToolbarAlignment/index.js +1 -1
- package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +3 -4
- package/dist/esm/plugins/floating-toolbar/index.js +1 -1
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +1 -1
- package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +1 -1
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -2
- package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -1
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +2 -2
- package/dist/esm/plugins/panel/toolbar.js +1 -1
- package/dist/esm/plugins/text-color/pm-plugins/main.js +2 -2
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +3 -3
- package/dist/esm/ui/Dropdown/index.js +1 -21
- package/dist/esm/utils/index.js +1 -9
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/actions/index.d.ts +1 -1
- package/dist/types/plugins/find-replace/ui/FindReplaceToolbarButton.d.ts +3 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
- package/dist/types/plugins/text-color/pm-plugins/main.d.ts +1 -1
- package/dist/types/ui/ConfigPanel/Fields/ColorPicker.d.ts +1 -1
- package/dist/types/ui/Dropdown/index.d.ts +2 -6
- package/dist/types/utils/index.d.ts +3 -5
- package/dist/types-ts4.5/actions/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/find-replace/ui/FindReplaceToolbarButton.d.ts +3 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/text-color/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/ColorPicker.d.ts +1 -1
- package/dist/types-ts4.5/ui/Dropdown/index.d.ts +2 -6
- package/dist/types-ts4.5/utils/index.d.ts +3 -5
- package/package.json +2 -2
- package/dist/cjs/ui/ColorPickerButton/index.js +0 -205
- package/dist/es2019/ui/ColorPickerButton/index.js +0 -213
- package/dist/esm/ui/ColorPickerButton/index.js +0 -198
- package/dist/types/ui/ColorPickerButton/index.d.ts +0 -28
- package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +0 -28
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { ArrowKeyNavigationProvider, ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
-
import { getSelectedRowAndColumnFromPalette } from '@atlaskit/editor-common/ui-color';
|
|
7
|
-
import Button from '@atlaskit/button';
|
|
8
|
-
import Tooltip from '@atlaskit/tooltip';
|
|
9
|
-
import { DN50, N0, N60A, N30A } from '@atlaskit/theme/colors';
|
|
10
|
-
import { themed } from '@atlaskit/theme/components';
|
|
11
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
12
|
-
import ColorPalette from '../ColorPalette';
|
|
13
|
-
import { DEFAULT_BORDER_COLOR } from '../ColorPalette/Palettes/common';
|
|
14
|
-
import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
15
|
-
import { editorAnalyticsChannel } from '../../plugins/analytics/consts';
|
|
16
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../plugins/analytics/types';
|
|
17
|
-
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
18
|
-
|
|
19
|
-
// helps adjusts position of popup
|
|
20
|
-
const colorPickerButtonWrapper = css`
|
|
21
|
-
position: relative;
|
|
22
|
-
`;
|
|
23
|
-
const colorPickerExpandContainer = css`
|
|
24
|
-
margin: 0px ${"var(--ds-space-negative-050, -4px)"};
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
// Control the size of color picker buttons and preview
|
|
28
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4134
|
|
29
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
30
|
-
const colorPickerWrapper = theme => css`
|
|
31
|
-
border-radius: ${borderRadius()}px;
|
|
32
|
-
background-color: ${themed({
|
|
33
|
-
light: `var(--ds-surface-overlay, ${N0})`,
|
|
34
|
-
dark: `var(--ds-surface-overlay, ${DN50})`
|
|
35
|
-
})(theme)};
|
|
36
|
-
box-shadow: 0 4px 8px -2px ${N60A}, 0 0 1px ${N60A};
|
|
37
|
-
padding: ${"var(--ds-space-100, 8px)"} 0px;
|
|
38
|
-
`;
|
|
39
|
-
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
40
|
-
|
|
41
|
-
const ColorPaletteWithListeners = withOuterListeners(ColorPalette);
|
|
42
|
-
const ColorPickerButton = props => {
|
|
43
|
-
const buttonRef = React.useRef(null);
|
|
44
|
-
const [isPopupOpen, setIsPopupOpen] = React.useState(false);
|
|
45
|
-
const [isPopupPositioned, setIsPopupPositioned] = React.useState(false);
|
|
46
|
-
const [isOpenedByKeyboard, setIsOpenedByKeyboard] = React.useState(false);
|
|
47
|
-
const togglePopup = () => {
|
|
48
|
-
setIsPopupOpen(!isPopupOpen);
|
|
49
|
-
if (!isPopupOpen) {
|
|
50
|
-
setIsOpenedByKeyboard(false);
|
|
51
|
-
setIsPopupPositioned(false);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
React.useEffect(() => {
|
|
55
|
-
if (props.setDisableParentScroll) {
|
|
56
|
-
props.setDisableParentScroll(isPopupOpen);
|
|
57
|
-
}
|
|
58
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
-
}, [isPopupOpen]);
|
|
60
|
-
const focusButton = () => {
|
|
61
|
-
var _buttonRef$current;
|
|
62
|
-
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
63
|
-
};
|
|
64
|
-
const handleEsc = React.useCallback(() => {
|
|
65
|
-
setIsOpenedByKeyboard(false);
|
|
66
|
-
setIsPopupPositioned(false);
|
|
67
|
-
setIsPopupOpen(false);
|
|
68
|
-
focusButton();
|
|
69
|
-
}, []);
|
|
70
|
-
const onPositionCalculated = React.useCallback(position => {
|
|
71
|
-
setIsPopupPositioned(true);
|
|
72
|
-
return position;
|
|
73
|
-
}, []);
|
|
74
|
-
const {
|
|
75
|
-
onChange,
|
|
76
|
-
createAnalyticsEvent,
|
|
77
|
-
colorPalette,
|
|
78
|
-
placement,
|
|
79
|
-
skipFocusButtonAfterPick
|
|
80
|
-
} = props;
|
|
81
|
-
const onColorSelected = React.useCallback((color, label) => {
|
|
82
|
-
setIsOpenedByKeyboard(false);
|
|
83
|
-
setIsPopupOpen(false);
|
|
84
|
-
setIsPopupPositioned(false);
|
|
85
|
-
if (onChange) {
|
|
86
|
-
if (createAnalyticsEvent) {
|
|
87
|
-
// fire analytics
|
|
88
|
-
const payload = {
|
|
89
|
-
action: ACTION.UPDATED,
|
|
90
|
-
actionSubject: ACTION_SUBJECT.PICKER,
|
|
91
|
-
actionSubjectId: ACTION_SUBJECT_ID.PICKER_COLOR,
|
|
92
|
-
attributes: {
|
|
93
|
-
color,
|
|
94
|
-
label,
|
|
95
|
-
placement: placement
|
|
96
|
-
},
|
|
97
|
-
eventType: EVENT_TYPE.TRACK
|
|
98
|
-
};
|
|
99
|
-
createAnalyticsEvent(payload).fire(editorAnalyticsChannel);
|
|
100
|
-
}
|
|
101
|
-
const newPalette = colorPalette.find(colorPalette => colorPalette.value === color);
|
|
102
|
-
newPalette && onChange(newPalette);
|
|
103
|
-
}
|
|
104
|
-
if (!skipFocusButtonAfterPick) {
|
|
105
|
-
focusButton();
|
|
106
|
-
}
|
|
107
|
-
}, [colorPalette, onChange, createAnalyticsEvent, placement, skipFocusButtonAfterPick]);
|
|
108
|
-
const renderPopup = () => {
|
|
109
|
-
if (!isPopupOpen || !buttonRef.current) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const selectedColor = props.currentColor || null;
|
|
113
|
-
const {
|
|
114
|
-
selectedRowIndex,
|
|
115
|
-
selectedColumnIndex
|
|
116
|
-
} = getSelectedRowAndColumnFromPalette(props.colorPalette, selectedColor, props.cols);
|
|
117
|
-
return jsx(Popup, {
|
|
118
|
-
target: buttonRef.current,
|
|
119
|
-
fitHeight: 350,
|
|
120
|
-
fitWidth: 350,
|
|
121
|
-
offset: [0, 10],
|
|
122
|
-
alignX: props.alignX,
|
|
123
|
-
mountTo: props.setDisableParentScroll ? props.mountPoint : undefined
|
|
124
|
-
// Confluence inline comment editor has z-index: 500
|
|
125
|
-
// if the toolbar is scrollable, this will be mounted in the root editor
|
|
126
|
-
// we need an index of > 500 to display over it
|
|
127
|
-
,
|
|
128
|
-
zIndex: props.setDisableParentScroll ? 600 : undefined,
|
|
129
|
-
ariaLabel: "Color picker popup",
|
|
130
|
-
onPositionCalculated: onPositionCalculated
|
|
131
|
-
}, jsx("div", {
|
|
132
|
-
css: colorPickerWrapper,
|
|
133
|
-
"data-test-id": "color-picker-menu"
|
|
134
|
-
}, jsx(ArrowKeyNavigationProvider, {
|
|
135
|
-
type: ArrowKeyNavigationType.COLOR,
|
|
136
|
-
selectedRowIndex: selectedRowIndex,
|
|
137
|
-
selectedColumnIndex: selectedColumnIndex,
|
|
138
|
-
closeOnTab: true,
|
|
139
|
-
handleClose: () => setIsPopupOpen(false),
|
|
140
|
-
isOpenedByKeyboard: isOpenedByKeyboard,
|
|
141
|
-
isPopupPositioned: isPopupPositioned
|
|
142
|
-
}, jsx(ColorPaletteWithListeners, {
|
|
143
|
-
cols: props.cols,
|
|
144
|
-
selectedColor: selectedColor,
|
|
145
|
-
onClick: onColorSelected,
|
|
146
|
-
handleClickOutside: togglePopup,
|
|
147
|
-
handleEscapeKeydown: handleEsc,
|
|
148
|
-
paletteOptions: {
|
|
149
|
-
palette: props.colorPalette,
|
|
150
|
-
hexToPaletteColor: props.hexToPaletteColor,
|
|
151
|
-
paletteColorTooltipMessages: props.paletteColorTooltipMessages
|
|
152
|
-
}
|
|
153
|
-
}))));
|
|
154
|
-
};
|
|
155
|
-
const title = props.title || '';
|
|
156
|
-
const currentColor = props.currentColor && props.hexToPaletteColor ? props.hexToPaletteColor(props.currentColor) : props.currentColor;
|
|
157
|
-
const buttonStyle = theme => {
|
|
158
|
-
var _props$size, _props$size2, _props$size3;
|
|
159
|
-
return css`
|
|
160
|
-
padding: 0 10px;
|
|
161
|
-
background-color: ${"var(--ds-background-neutral-subtle, transparent)"};
|
|
162
|
-
${
|
|
163
|
-
/* If custom props size height, override the button base height property */!!((_props$size = props.size) !== null && _props$size !== void 0 && _props$size.height) && `height: inherit;`}
|
|
164
|
-
&:before {
|
|
165
|
-
display: flex;
|
|
166
|
-
justify-content: center;
|
|
167
|
-
align-items: center;
|
|
168
|
-
align-self: center;
|
|
169
|
-
content: '';
|
|
170
|
-
border: 1px solid ${DEFAULT_BORDER_COLOR};
|
|
171
|
-
border-radius: ${borderRadius()}px;
|
|
172
|
-
background-color: ${currentColor || 'transparent'};
|
|
173
|
-
width: ${((_props$size2 = props.size) === null || _props$size2 === void 0 ? void 0 : _props$size2.width) || '14px'};
|
|
174
|
-
height: ${((_props$size3 = props.size) === null || _props$size3 === void 0 ? void 0 : _props$size3.height) || '14px'};
|
|
175
|
-
padding: 0;
|
|
176
|
-
margin: 0px ${"var(--ds-space-025, 2px)"};
|
|
177
|
-
}
|
|
178
|
-
&:hover {
|
|
179
|
-
background: ${themed({
|
|
180
|
-
light: `var(--ds-background-neutral-subtle-hovered, ${N30A})`,
|
|
181
|
-
dark: `var(--ds-background-neutral-subtle-hovered, ${N30A})`
|
|
182
|
-
})(theme)};
|
|
183
|
-
}
|
|
184
|
-
`;
|
|
185
|
-
};
|
|
186
|
-
return jsx("div", {
|
|
187
|
-
css: colorPickerButtonWrapper
|
|
188
|
-
}, jsx(Tooltip, {
|
|
189
|
-
content: title,
|
|
190
|
-
position: "top"
|
|
191
|
-
}, jsx(Button, {
|
|
192
|
-
ref: buttonRef,
|
|
193
|
-
"aria-label": title,
|
|
194
|
-
spacing: "compact",
|
|
195
|
-
onClick: togglePopup,
|
|
196
|
-
onKeyDown: event => {
|
|
197
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
198
|
-
event.preventDefault();
|
|
199
|
-
togglePopup();
|
|
200
|
-
setIsOpenedByKeyboard(true);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
css: buttonStyle,
|
|
204
|
-
iconAfter: jsx("span", {
|
|
205
|
-
css: colorPickerExpandContainer
|
|
206
|
-
}, jsx(ExpandIcon, {
|
|
207
|
-
label: ""
|
|
208
|
-
}))
|
|
209
|
-
})), renderPopup());
|
|
210
|
-
};
|
|
211
|
-
export default withAnalyticsContext({
|
|
212
|
-
source: 'ConfigPanel'
|
|
213
|
-
})(withAnalyticsEvents()(ColorPickerButton));
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
|
-
/** @jsx jsx */
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { css, jsx } from '@emotion/react';
|
|
7
|
-
import { Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
8
|
-
import { ArrowKeyNavigationProvider, ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
|
|
9
|
-
import { getSelectedRowAndColumnFromPalette } from '@atlaskit/editor-common/ui-color';
|
|
10
|
-
import Button from '@atlaskit/button';
|
|
11
|
-
import Tooltip from '@atlaskit/tooltip';
|
|
12
|
-
import { DN50, N0, N60A, N30A } from '@atlaskit/theme/colors';
|
|
13
|
-
import { themed } from '@atlaskit/theme/components';
|
|
14
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
15
|
-
import ColorPalette from '../ColorPalette';
|
|
16
|
-
import { DEFAULT_BORDER_COLOR } from '../ColorPalette/Palettes/common';
|
|
17
|
-
import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
18
|
-
import { editorAnalyticsChannel } from '../../plugins/analytics/consts';
|
|
19
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../plugins/analytics/types';
|
|
20
|
-
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
21
|
-
|
|
22
|
-
// helps adjusts position of popup
|
|
23
|
-
var colorPickerButtonWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
|
|
24
|
-
var colorPickerExpandContainer = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin: 0px ", ";\n"])), "var(--ds-space-negative-050, -4px)");
|
|
25
|
-
|
|
26
|
-
// Control the size of color picker buttons and preview
|
|
27
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4134
|
|
28
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
29
|
-
var colorPickerWrapper = function colorPickerWrapper(theme) {
|
|
30
|
-
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border-radius: ", "px;\n background-color: ", ";\n box-shadow: 0 4px 8px -2px ", ", 0 0 1px ", ";\n padding: ", " 0px;\n"])), borderRadius(), themed({
|
|
31
|
-
light: "var(--ds-surface-overlay, ".concat(N0, ")"),
|
|
32
|
-
dark: "var(--ds-surface-overlay, ".concat(DN50, ")")
|
|
33
|
-
})(theme), N60A, N60A, "var(--ds-space-100, 8px)");
|
|
34
|
-
};
|
|
35
|
-
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
36
|
-
|
|
37
|
-
var ColorPaletteWithListeners = withOuterListeners(ColorPalette);
|
|
38
|
-
var ColorPickerButton = function ColorPickerButton(props) {
|
|
39
|
-
var buttonRef = React.useRef(null);
|
|
40
|
-
var _React$useState = React.useState(false),
|
|
41
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
42
|
-
isPopupOpen = _React$useState2[0],
|
|
43
|
-
setIsPopupOpen = _React$useState2[1];
|
|
44
|
-
var _React$useState3 = React.useState(false),
|
|
45
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
46
|
-
isPopupPositioned = _React$useState4[0],
|
|
47
|
-
setIsPopupPositioned = _React$useState4[1];
|
|
48
|
-
var _React$useState5 = React.useState(false),
|
|
49
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
50
|
-
isOpenedByKeyboard = _React$useState6[0],
|
|
51
|
-
setIsOpenedByKeyboard = _React$useState6[1];
|
|
52
|
-
var togglePopup = function togglePopup() {
|
|
53
|
-
setIsPopupOpen(!isPopupOpen);
|
|
54
|
-
if (!isPopupOpen) {
|
|
55
|
-
setIsOpenedByKeyboard(false);
|
|
56
|
-
setIsPopupPositioned(false);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
React.useEffect(function () {
|
|
60
|
-
if (props.setDisableParentScroll) {
|
|
61
|
-
props.setDisableParentScroll(isPopupOpen);
|
|
62
|
-
}
|
|
63
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
}, [isPopupOpen]);
|
|
65
|
-
var focusButton = function focusButton() {
|
|
66
|
-
var _buttonRef$current;
|
|
67
|
-
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
68
|
-
};
|
|
69
|
-
var handleEsc = React.useCallback(function () {
|
|
70
|
-
setIsOpenedByKeyboard(false);
|
|
71
|
-
setIsPopupPositioned(false);
|
|
72
|
-
setIsPopupOpen(false);
|
|
73
|
-
focusButton();
|
|
74
|
-
}, []);
|
|
75
|
-
var onPositionCalculated = React.useCallback(function (position) {
|
|
76
|
-
setIsPopupPositioned(true);
|
|
77
|
-
return position;
|
|
78
|
-
}, []);
|
|
79
|
-
var onChange = props.onChange,
|
|
80
|
-
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
81
|
-
colorPalette = props.colorPalette,
|
|
82
|
-
placement = props.placement,
|
|
83
|
-
skipFocusButtonAfterPick = props.skipFocusButtonAfterPick;
|
|
84
|
-
var onColorSelected = React.useCallback(function (color, label) {
|
|
85
|
-
setIsOpenedByKeyboard(false);
|
|
86
|
-
setIsPopupOpen(false);
|
|
87
|
-
setIsPopupPositioned(false);
|
|
88
|
-
if (onChange) {
|
|
89
|
-
if (createAnalyticsEvent) {
|
|
90
|
-
// fire analytics
|
|
91
|
-
var payload = {
|
|
92
|
-
action: ACTION.UPDATED,
|
|
93
|
-
actionSubject: ACTION_SUBJECT.PICKER,
|
|
94
|
-
actionSubjectId: ACTION_SUBJECT_ID.PICKER_COLOR,
|
|
95
|
-
attributes: {
|
|
96
|
-
color: color,
|
|
97
|
-
label: label,
|
|
98
|
-
placement: placement
|
|
99
|
-
},
|
|
100
|
-
eventType: EVENT_TYPE.TRACK
|
|
101
|
-
};
|
|
102
|
-
createAnalyticsEvent(payload).fire(editorAnalyticsChannel);
|
|
103
|
-
}
|
|
104
|
-
var newPalette = colorPalette.find(function (colorPalette) {
|
|
105
|
-
return colorPalette.value === color;
|
|
106
|
-
});
|
|
107
|
-
newPalette && onChange(newPalette);
|
|
108
|
-
}
|
|
109
|
-
if (!skipFocusButtonAfterPick) {
|
|
110
|
-
focusButton();
|
|
111
|
-
}
|
|
112
|
-
}, [colorPalette, onChange, createAnalyticsEvent, placement, skipFocusButtonAfterPick]);
|
|
113
|
-
var renderPopup = function renderPopup() {
|
|
114
|
-
if (!isPopupOpen || !buttonRef.current) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
var selectedColor = props.currentColor || null;
|
|
118
|
-
var _getSelectedRowAndCol = getSelectedRowAndColumnFromPalette(props.colorPalette, selectedColor, props.cols),
|
|
119
|
-
selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
|
|
120
|
-
selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
|
|
121
|
-
return jsx(Popup, {
|
|
122
|
-
target: buttonRef.current,
|
|
123
|
-
fitHeight: 350,
|
|
124
|
-
fitWidth: 350,
|
|
125
|
-
offset: [0, 10],
|
|
126
|
-
alignX: props.alignX,
|
|
127
|
-
mountTo: props.setDisableParentScroll ? props.mountPoint : undefined
|
|
128
|
-
// Confluence inline comment editor has z-index: 500
|
|
129
|
-
// if the toolbar is scrollable, this will be mounted in the root editor
|
|
130
|
-
// we need an index of > 500 to display over it
|
|
131
|
-
,
|
|
132
|
-
zIndex: props.setDisableParentScroll ? 600 : undefined,
|
|
133
|
-
ariaLabel: "Color picker popup",
|
|
134
|
-
onPositionCalculated: onPositionCalculated
|
|
135
|
-
}, jsx("div", {
|
|
136
|
-
css: colorPickerWrapper,
|
|
137
|
-
"data-test-id": "color-picker-menu"
|
|
138
|
-
}, jsx(ArrowKeyNavigationProvider, {
|
|
139
|
-
type: ArrowKeyNavigationType.COLOR,
|
|
140
|
-
selectedRowIndex: selectedRowIndex,
|
|
141
|
-
selectedColumnIndex: selectedColumnIndex,
|
|
142
|
-
closeOnTab: true,
|
|
143
|
-
handleClose: function handleClose() {
|
|
144
|
-
return setIsPopupOpen(false);
|
|
145
|
-
},
|
|
146
|
-
isOpenedByKeyboard: isOpenedByKeyboard,
|
|
147
|
-
isPopupPositioned: isPopupPositioned
|
|
148
|
-
}, jsx(ColorPaletteWithListeners, {
|
|
149
|
-
cols: props.cols,
|
|
150
|
-
selectedColor: selectedColor,
|
|
151
|
-
onClick: onColorSelected,
|
|
152
|
-
handleClickOutside: togglePopup,
|
|
153
|
-
handleEscapeKeydown: handleEsc,
|
|
154
|
-
paletteOptions: {
|
|
155
|
-
palette: props.colorPalette,
|
|
156
|
-
hexToPaletteColor: props.hexToPaletteColor,
|
|
157
|
-
paletteColorTooltipMessages: props.paletteColorTooltipMessages
|
|
158
|
-
}
|
|
159
|
-
}))));
|
|
160
|
-
};
|
|
161
|
-
var title = props.title || '';
|
|
162
|
-
var currentColor = props.currentColor && props.hexToPaletteColor ? props.hexToPaletteColor(props.currentColor) : props.currentColor;
|
|
163
|
-
var buttonStyle = function buttonStyle(theme) {
|
|
164
|
-
var _props$size, _props$size2, _props$size3;
|
|
165
|
-
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 0 10px;\n background-color: ", ";\n ", "\n &:before {\n display: flex;\n justify-content: center;\n align-items: center;\n align-self: center;\n content: '';\n border: 1px solid ", ";\n border-radius: ", "px;\n background-color: ", ";\n width: ", ";\n height: ", ";\n padding: 0;\n margin: 0px ", ";\n }\n &:hover {\n background: ", ";\n }\n "])), "var(--ds-background-neutral-subtle, transparent)", /* If custom props size height, override the button base height property */
|
|
166
|
-
!!((_props$size = props.size) !== null && _props$size !== void 0 && _props$size.height) && "height: inherit;", DEFAULT_BORDER_COLOR, borderRadius(), currentColor || 'transparent', ((_props$size2 = props.size) === null || _props$size2 === void 0 ? void 0 : _props$size2.width) || '14px', ((_props$size3 = props.size) === null || _props$size3 === void 0 ? void 0 : _props$size3.height) || '14px', "var(--ds-space-025, 2px)", themed({
|
|
167
|
-
light: "var(--ds-background-neutral-subtle-hovered, ".concat(N30A, ")"),
|
|
168
|
-
dark: "var(--ds-background-neutral-subtle-hovered, ".concat(N30A, ")")
|
|
169
|
-
})(theme));
|
|
170
|
-
};
|
|
171
|
-
return jsx("div", {
|
|
172
|
-
css: colorPickerButtonWrapper
|
|
173
|
-
}, jsx(Tooltip, {
|
|
174
|
-
content: title,
|
|
175
|
-
position: "top"
|
|
176
|
-
}, jsx(Button, {
|
|
177
|
-
ref: buttonRef,
|
|
178
|
-
"aria-label": title,
|
|
179
|
-
spacing: "compact",
|
|
180
|
-
onClick: togglePopup,
|
|
181
|
-
onKeyDown: function onKeyDown(event) {
|
|
182
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
183
|
-
event.preventDefault();
|
|
184
|
-
togglePopup();
|
|
185
|
-
setIsOpenedByKeyboard(true);
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
css: buttonStyle,
|
|
189
|
-
iconAfter: jsx("span", {
|
|
190
|
-
css: colorPickerExpandContainer
|
|
191
|
-
}, jsx(ExpandIcon, {
|
|
192
|
-
label: ""
|
|
193
|
-
}))
|
|
194
|
-
})), renderPopup());
|
|
195
|
-
};
|
|
196
|
-
export default withAnalyticsContext({
|
|
197
|
-
source: 'ConfigPanel'
|
|
198
|
-
})(withAnalyticsEvents()(ColorPickerButton));
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { PaletteColor, PaletteTooltipMessages } from '../ColorPalette/Palettes';
|
|
4
|
-
import type { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
5
|
-
type Props = WithAnalyticsEventsProps & {
|
|
6
|
-
currentColor?: string;
|
|
7
|
-
title?: string;
|
|
8
|
-
onChange?: (color: PaletteColor) => void;
|
|
9
|
-
colorPalette: PaletteColor[];
|
|
10
|
-
placement: string;
|
|
11
|
-
cols?: number;
|
|
12
|
-
alignX?: 'left' | 'right' | 'center' | 'end';
|
|
13
|
-
size?: {
|
|
14
|
-
width: string;
|
|
15
|
-
height: string;
|
|
16
|
-
};
|
|
17
|
-
mountPoint?: HTMLElement;
|
|
18
|
-
setDisableParentScroll?: (disable: boolean) => void;
|
|
19
|
-
hexToPaletteColor?: (hexColor: string) => string | undefined;
|
|
20
|
-
paletteColorTooltipMessages?: PaletteTooltipMessages;
|
|
21
|
-
/**
|
|
22
|
-
* After picking the color the default behaviour is to focus the color picker button.
|
|
23
|
-
* To prevent this use skipFocusButtonAfterPick.
|
|
24
|
-
*/
|
|
25
|
-
skipFocusButtonAfterPick?: boolean;
|
|
26
|
-
};
|
|
27
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "title" | "key" | "onChange" | "size" | "currentColor" | "cols" | "analyticsContext" | "alignX" | "colorPalette" | "placement" | "mountPoint" | "setDisableParentScroll" | "hexToPaletteColor" | "paletteColorTooltipMessages" | "skipFocusButtonAfterPick"> & React.RefAttributes<any>>;
|
|
28
|
-
export default _default;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { PaletteColor, PaletteTooltipMessages } from '../ColorPalette/Palettes';
|
|
4
|
-
import type { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
5
|
-
type Props = WithAnalyticsEventsProps & {
|
|
6
|
-
currentColor?: string;
|
|
7
|
-
title?: string;
|
|
8
|
-
onChange?: (color: PaletteColor) => void;
|
|
9
|
-
colorPalette: PaletteColor[];
|
|
10
|
-
placement: string;
|
|
11
|
-
cols?: number;
|
|
12
|
-
alignX?: 'left' | 'right' | 'center' | 'end';
|
|
13
|
-
size?: {
|
|
14
|
-
width: string;
|
|
15
|
-
height: string;
|
|
16
|
-
};
|
|
17
|
-
mountPoint?: HTMLElement;
|
|
18
|
-
setDisableParentScroll?: (disable: boolean) => void;
|
|
19
|
-
hexToPaletteColor?: (hexColor: string) => string | undefined;
|
|
20
|
-
paletteColorTooltipMessages?: PaletteTooltipMessages;
|
|
21
|
-
/**
|
|
22
|
-
* After picking the color the default behaviour is to focus the color picker button.
|
|
23
|
-
* To prevent this use skipFocusButtonAfterPick.
|
|
24
|
-
*/
|
|
25
|
-
skipFocusButtonAfterPick?: boolean;
|
|
26
|
-
};
|
|
27
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "title" | "key" | "onChange" | "size" | "currentColor" | "cols" | "analyticsContext" | "alignX" | "colorPalette" | "placement" | "mountPoint" | "setDisableParentScroll" | "hexToPaletteColor" | "paletteColorTooltipMessages" | "skipFocusButtonAfterPick"> & React.RefAttributes<any>>;
|
|
28
|
-
export default _default;
|