@atlaskit/editor-common 72.4.1 → 72.5.1
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 +58 -0
- package/dist/cjs/analytics/analytics-queue.js +79 -0
- package/dist/cjs/analytics/fire-analytics-event.js +36 -0
- package/dist/cjs/analytics/index.js +15 -1
- package/dist/cjs/analytics/types/enums.js +4 -0
- package/dist/cjs/analytics/utils.js +16 -0
- package/dist/cjs/hooks/index.js +20 -0
- package/dist/cjs/hooks/useConstructor.js +22 -0
- package/dist/cjs/hooks/usePreviousState.js +23 -0
- package/dist/cjs/keymaps/index.js +1 -1
- package/dist/cjs/styles/index.js +6 -0
- package/dist/cjs/styles/shared/table.js +3 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/index.js +6 -0
- package/dist/cjs/ui-color/ColorPalette/Color/index.js +2 -3
- package/dist/cjs/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -1
- package/dist/cjs/ui-color/ColorPalette/index.js +9 -11
- package/dist/cjs/ui-color/ColorPalette/utils.js +42 -0
- package/dist/cjs/ui-color/index.js +25 -0
- package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +141 -0
- package/dist/cjs/ui-menu/{MenuArrowKeyNavigationProvider → ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider}/index.js +15 -0
- package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/index.js +29 -0
- package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/types.js +12 -0
- package/dist/cjs/ui-menu/Dropdown/index.js +5 -7
- package/dist/cjs/ui-menu/DropdownMenu/index.js +50 -24
- package/dist/cjs/ui-menu/ToolbarButton/index.js +3 -1
- package/dist/cjs/ui-menu/index.js +21 -0
- package/dist/cjs/utils/analytics.js +5 -1
- package/dist/cjs/utils/index.js +6 -0
- package/dist/cjs/utils/referentiality.js +29 -15
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/analytics-queue.js +53 -0
- package/dist/es2019/analytics/fire-analytics-event.js +27 -0
- package/dist/es2019/analytics/index.js +3 -1
- package/dist/es2019/analytics/types/enums.js +4 -0
- package/dist/es2019/analytics/utils.js +4 -0
- package/dist/es2019/hooks/index.js +2 -0
- package/dist/es2019/hooks/useConstructor.js +17 -0
- package/dist/es2019/hooks/usePreviousState.js +18 -0
- package/dist/es2019/keymaps/index.js +1 -1
- package/dist/es2019/styles/index.js +1 -1
- package/dist/es2019/styles/shared/table.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/index.js +1 -1
- package/dist/es2019/ui-color/ColorPalette/Color/index.js +7 -4
- package/dist/es2019/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -1
- package/dist/es2019/ui-color/ColorPalette/index.js +9 -11
- package/dist/es2019/ui-color/ColorPalette/utils.js +31 -0
- package/dist/es2019/ui-color/index.js +1 -0
- package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +132 -0
- package/dist/es2019/ui-menu/{MenuArrowKeyNavigationProvider → ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider}/index.js +16 -1
- package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/index.js +21 -0
- package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/types.js +5 -0
- package/dist/es2019/ui-menu/Dropdown/index.js +5 -7
- package/dist/es2019/ui-menu/DropdownMenu/index.js +46 -23
- package/dist/es2019/ui-menu/ToolbarButton/index.js +3 -1
- package/dist/es2019/ui-menu/index.js +3 -0
- package/dist/es2019/utils/analytics.js +1 -0
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/referentiality.js +19 -15
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/analytics-queue.js +71 -0
- package/dist/esm/analytics/fire-analytics-event.js +29 -0
- package/dist/esm/analytics/index.js +3 -1
- package/dist/esm/analytics/types/enums.js +4 -0
- package/dist/esm/analytics/utils.js +9 -0
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/useConstructor.js +17 -0
- package/dist/esm/hooks/usePreviousState.js +18 -0
- package/dist/esm/keymaps/index.js +1 -1
- package/dist/esm/styles/index.js +1 -1
- package/dist/esm/styles/shared/table.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/index.js +1 -1
- package/dist/esm/ui-color/ColorPalette/Color/index.js +2 -3
- package/dist/esm/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -1
- package/dist/esm/ui-color/ColorPalette/index.js +9 -11
- package/dist/esm/ui-color/ColorPalette/utils.js +32 -0
- package/dist/esm/ui-color/index.js +1 -0
- package/dist/esm/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +131 -0
- package/dist/esm/ui-menu/{MenuArrowKeyNavigationProvider → ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider}/index.js +16 -1
- package/dist/esm/ui-menu/ArrowKeyNavigationProvider/index.js +21 -0
- package/dist/esm/ui-menu/ArrowKeyNavigationProvider/types.js +5 -0
- package/dist/esm/ui-menu/Dropdown/index.js +5 -7
- package/dist/esm/ui-menu/DropdownMenu/index.js +50 -24
- package/dist/esm/ui-menu/ToolbarButton/index.js +3 -1
- package/dist/esm/ui-menu/index.js +3 -0
- package/dist/esm/utils/analytics.js +3 -0
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/referentiality.js +28 -15
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/analytics-queue.d.ts +10 -0
- package/dist/types/analytics/fire-analytics-event.d.ts +2 -0
- package/dist/types/analytics/index.d.ts +3 -1
- package/dist/types/analytics/types/enums.d.ts +4 -0
- package/dist/types/analytics/types/events.d.ts +2 -1
- package/dist/types/analytics/types/general-events.d.ts +2 -2
- package/dist/types/analytics/types/index.d.ts +1 -1
- package/dist/types/analytics/utils.d.ts +3 -0
- package/dist/types/extensions/types/extension-manifest.d.ts +1 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/useConstructor.d.ts +9 -0
- package/dist/types/hooks/usePreviousState.d.ts +11 -0
- package/dist/types/styles/index.d.ts +1 -1
- package/dist/types/styles/shared/table.d.ts +1 -0
- package/dist/types/types/editor-actions.d.ts +2 -1
- package/dist/types/types/feature-flags.d.ts +11 -0
- package/dist/types/types/floating-toolbar.d.ts +1 -1
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/next-editor-plugin.d.ts +37 -32
- package/dist/types/ui/index.d.ts +1 -1
- package/dist/types/ui-color/ColorPalette/Color/index.d.ts +1 -5
- package/dist/types/ui-color/ColorPalette/index.d.ts +1 -0
- package/dist/types/ui-color/ColorPalette/utils.d.ts +11 -0
- package/dist/types/ui-color/index.d.ts +1 -0
- package/dist/types/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.d.ts +7 -0
- package/dist/types/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.d.ts +7 -0
- package/dist/types/ui-menu/ArrowKeyNavigationProvider/index.d.ts +3 -0
- package/dist/types/ui-menu/ArrowKeyNavigationProvider/types.d.ts +33 -0
- package/dist/types/ui-menu/Dropdown/index.d.ts +2 -3
- package/dist/types/ui-menu/DropdownMenu/index.d.ts +2 -0
- package/dist/types/ui-menu/DropdownMenu/types.d.ts +3 -6
- package/dist/types/ui-menu/ToolbarButton/index.d.ts +2 -0
- package/dist/types/ui-menu/index.d.ts +3 -0
- package/dist/types/utils/analytics.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/referentiality.d.ts +11 -0
- package/hooks/package.json +15 -0
- package/package.json +16 -12
- package/dist/types/ui-menu/MenuArrowKeyNavigationProvider/index.d.ts +0 -16
|
@@ -33,6 +33,7 @@ const ToolbarButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
33
33
|
'aria-pressed': ariaPressed,
|
|
34
34
|
'aria-keyshortcuts': ariaKeyShortcuts,
|
|
35
35
|
onClick,
|
|
36
|
+
onKeyDown,
|
|
36
37
|
onItemClick
|
|
37
38
|
} = props;
|
|
38
39
|
const handleClick = useCallback((event, analyticsEvent) => {
|
|
@@ -75,7 +76,8 @@ const ToolbarButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
75
76
|
"aria-haspopup": ariaHasPopup,
|
|
76
77
|
"aria-label": ariaLabel,
|
|
77
78
|
"aria-pressed": ariaPressed,
|
|
78
|
-
"aria-keyshortcuts": ariaKeyShortcuts
|
|
79
|
+
"aria-keyshortcuts": ariaKeyShortcuts,
|
|
80
|
+
onKeyDown: onKeyDown
|
|
79
81
|
}, children);
|
|
80
82
|
if (!title) {
|
|
81
83
|
return button;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default as DropdownMenu } from '../ui-menu/DropdownMenu';
|
|
2
2
|
export { default as ToolbarButton, TOOLBAR_BUTTON } from '../ui-menu/ToolbarButton';
|
|
3
|
+
export { ArrowKeyNavigationProvider } from '../ui-menu/ArrowKeyNavigationProvider';
|
|
4
|
+
export { ArrowKeyNavigationType } from '../ui-menu/ArrowKeyNavigationProvider/types';
|
|
5
|
+
export { ColorPaletteArrowKeyNavigationProvider } from './ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider';
|
|
3
6
|
export { default as Dropdown } from './Dropdown';
|
|
@@ -13,6 +13,7 @@ export const getAnalyticsAppearance = appearance => {
|
|
|
13
13
|
return EDITOR_APPEARANCE_CONTEXT.MOBILE;
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
+
export const getAnalyticsEditorAppearance = editorAppearance => editorAppearance ? `editor_${getAnalyticsAppearance(editorAppearance)}` : '_unknown';
|
|
16
17
|
export const getAnalyticsEventSeverity = (duration, normalThreshold, degradedThreshold) => {
|
|
17
18
|
if (duration > normalThreshold && duration <= degradedThreshold) {
|
|
18
19
|
return SEVERITY.DEGRADED;
|
|
@@ -11,7 +11,7 @@ export { pluginFactory } from './plugin-state-factory';
|
|
|
11
11
|
export { getFragmentBackingArray, mapFragment, mapSlice, flatmap, mapChildren } from './slice';
|
|
12
12
|
export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, closest, closestElement, parsePx, mapElem, maphElem } from './dom';
|
|
13
13
|
export { default as ADFTraversor } from './traversor';
|
|
14
|
-
export { analyticsEventKey, getAnalyticsAppearance, getAnalyticsEventSeverity, SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS } from './analytics';
|
|
14
|
+
export { analyticsEventKey, getAnalyticsAppearance, getAnalyticsEditorAppearance, getAnalyticsEventSeverity, SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS } from './analytics';
|
|
15
15
|
export { findAndTrackUnsupportedContentNodes } from './track-unsupported-content';
|
|
16
16
|
export { getDistortedDurationMonitor, measureRender } from './performance/measure-render';
|
|
17
17
|
export { startMeasure, stopMeasure, clearMeasure } from './performance/measure';
|
|
@@ -27,7 +27,7 @@ export const isReferencedSource = (state, node) => {
|
|
|
27
27
|
});
|
|
28
28
|
return found;
|
|
29
29
|
};
|
|
30
|
-
const getConnections = state => {
|
|
30
|
+
export const getConnections = state => {
|
|
31
31
|
const result = {};
|
|
32
32
|
const {
|
|
33
33
|
doc,
|
|
@@ -42,7 +42,7 @@ const getConnections = state => {
|
|
|
42
42
|
// Perform a prelim scan creating the initial id to connection link mappings.
|
|
43
43
|
// This will also save a list of data sources consumed per node.
|
|
44
44
|
doc.descendants((node, pos) => {
|
|
45
|
-
var _node$attrs2, _fragmentMark$attrs$l, _fragmentMark, _fragmentMark$attrs, _node$attrs3, _fragmentMark2, _fragmentMark2$attrs, _node$attrs4,
|
|
45
|
+
var _node$attrs2, _fragmentMark$attrs$l, _fragmentMark, _fragmentMark$attrs, _node$attrs3, _fragmentMark2, _fragmentMark2$attrs, _node$attrs4, _fragmentMark3, _fragmentMark3$attrs;
|
|
46
46
|
let dataConsumer;
|
|
47
47
|
let fragmentMark;
|
|
48
48
|
node.marks.some(mark => {
|
|
@@ -76,7 +76,7 @@ const getConnections = state => {
|
|
|
76
76
|
}
|
|
77
77
|
result[normalizedId] = {
|
|
78
78
|
localId: normalizedId,
|
|
79
|
-
name: (
|
|
79
|
+
name: (_fragmentMark3 = fragmentMark) === null || _fragmentMark3 === void 0 ? void 0 : (_fragmentMark3$attrs = _fragmentMark3.attrs) === null || _fragmentMark3$attrs === void 0 ? void 0 : _fragmentMark3$attrs.name,
|
|
80
80
|
node,
|
|
81
81
|
pos,
|
|
82
82
|
targets: []
|
|
@@ -155,6 +155,7 @@ const getIdsToBeDeleted = (selectedIds, allNodes) => {
|
|
|
155
155
|
|
|
156
156
|
// for get children info for confirmation dialog
|
|
157
157
|
export const getChildrenInfo = (state, node) => {
|
|
158
|
+
let allChildrenHadName = true;
|
|
158
159
|
if (!node) {
|
|
159
160
|
return [];
|
|
160
161
|
}
|
|
@@ -167,14 +168,19 @@ export const getChildrenInfo = (state, node) => {
|
|
|
167
168
|
allNodes[id].targets.forEach(childrenIdSet.add, childrenIdSet);
|
|
168
169
|
}
|
|
169
170
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
171
|
+
for (const id of childrenIdSet) {
|
|
172
|
+
if (!getNodeNameById(id, allNodes)) {
|
|
173
|
+
allChildrenHadName = false;
|
|
174
|
+
break;
|
|
175
|
+
} else {
|
|
176
|
+
childrenInfoArray.push({
|
|
177
|
+
id,
|
|
178
|
+
name: getNodeNameById(id, allNodes),
|
|
179
|
+
amount: getChildrenNodeAmount(id, allNodes)
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return allChildrenHadName ? childrenInfoArray : [];
|
|
178
184
|
};
|
|
179
185
|
const getChildrenNodeAmount = (id, allNodes) => {
|
|
180
186
|
const searchTerms = new Set([id]);
|
|
@@ -203,19 +209,17 @@ const getNodeTargetsById = (id, allNodes) => {
|
|
|
203
209
|
}
|
|
204
210
|
return allNodes[id].targets;
|
|
205
211
|
};
|
|
206
|
-
const DEFAULT_EXTENSION_NAME = 'Default extension';
|
|
207
212
|
const getNodeNameById = (id, allNodes) => {
|
|
208
213
|
if (typeof id === 'object') {
|
|
209
|
-
var _name2;
|
|
210
214
|
let name;
|
|
211
215
|
id.forEach(localId => {
|
|
212
216
|
var _name, _allNodes$localId;
|
|
213
217
|
name = (_name = name) !== null && _name !== void 0 ? _name : (_allNodes$localId = allNodes[localId]) === null || _allNodes$localId === void 0 ? void 0 : _allNodes$localId.name;
|
|
214
218
|
});
|
|
215
|
-
return
|
|
219
|
+
return name || null;
|
|
216
220
|
}
|
|
217
221
|
if (!id || !allNodes[id]) {
|
|
218
|
-
return
|
|
222
|
+
return null;
|
|
219
223
|
}
|
|
220
224
|
return allNodes[id].name;
|
|
221
225
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import memoizeOne from 'memoize-one';
|
|
5
|
+
export var AnalyticsQueue = /*#__PURE__*/function () {
|
|
6
|
+
function AnalyticsQueue() {
|
|
7
|
+
_classCallCheck(this, AnalyticsQueue);
|
|
8
|
+
_defineProperty(this, "tasks", []);
|
|
9
|
+
_defineProperty(this, "running", false);
|
|
10
|
+
}
|
|
11
|
+
_createClass(AnalyticsQueue, [{
|
|
12
|
+
key: "request",
|
|
13
|
+
value: function request(fn) {
|
|
14
|
+
if (window.requestIdleCallback) {
|
|
15
|
+
window.requestIdleCallback(fn);
|
|
16
|
+
} else {
|
|
17
|
+
var start = performance.now();
|
|
18
|
+
setTimeout(function () {
|
|
19
|
+
fn({
|
|
20
|
+
didTimeout: false,
|
|
21
|
+
timeRemaining: function timeRemaining() {
|
|
22
|
+
return Math.max(0, 50 - (performance.now() - start));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}, 0);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, {
|
|
29
|
+
key: "pending",
|
|
30
|
+
value: function pending() {
|
|
31
|
+
var _window$navigator, _window$navigator$sch;
|
|
32
|
+
// Defensive coding as navigator.scheduling.isInputPending is an experimental API
|
|
33
|
+
if (typeof ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : (_window$navigator$sch = _window$navigator.scheduling) === null || _window$navigator$sch === void 0 ? void 0 : _window$navigator$sch.isInputPending) === 'function') {
|
|
34
|
+
var _window$navigator2, _window$navigator2$sc;
|
|
35
|
+
return ((_window$navigator2 = window.navigator) === null || _window$navigator2 === void 0 ? void 0 : (_window$navigator2$sc = _window$navigator2.scheduling) === null || _window$navigator2$sc === void 0 ? void 0 : _window$navigator2$sc.isInputPending()) === true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "process",
|
|
41
|
+
value: function process() {
|
|
42
|
+
var _this = this;
|
|
43
|
+
if (this.running) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.running = true;
|
|
47
|
+
this.request(function (deadline) {
|
|
48
|
+
while (deadline.timeRemaining() > 0 && _this.tasks.length > 0 && !_this.pending()) {
|
|
49
|
+
var task = _this.tasks.shift();
|
|
50
|
+
if (task) {
|
|
51
|
+
task();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
_this.running = false;
|
|
55
|
+
if (_this.tasks.length > 0) {
|
|
56
|
+
_this.process();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "schedule",
|
|
62
|
+
value: function schedule(task) {
|
|
63
|
+
this.tasks.push(task);
|
|
64
|
+
this.process();
|
|
65
|
+
}
|
|
66
|
+
}]);
|
|
67
|
+
return AnalyticsQueue;
|
|
68
|
+
}();
|
|
69
|
+
_defineProperty(AnalyticsQueue, "get", memoizeOne(function () {
|
|
70
|
+
return new AnalyticsQueue();
|
|
71
|
+
}));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
2
|
+
import { AnalyticsQueue } from './analytics-queue';
|
|
3
|
+
var editorAnalyticsChannel = FabricChannel.editor;
|
|
4
|
+
export var fireAnalyticsEvent = function fireAnalyticsEvent(createAnalyticsEvent) {
|
|
5
|
+
return function (_ref) {
|
|
6
|
+
var payload = _ref.payload,
|
|
7
|
+
_ref$channel = _ref.channel,
|
|
8
|
+
channel = _ref$channel === void 0 ? editorAnalyticsChannel : _ref$channel;
|
|
9
|
+
if (!createAnalyticsEvent) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// START TEMPORARY CODE ED-10584
|
|
14
|
+
// __queueAnalytics property set in ReactEditorView based on featureFlags.queueAnalytics
|
|
15
|
+
var queueAnalytics = Boolean(createAnalyticsEvent.__queueAnalytics);
|
|
16
|
+
// END TEMPORARY CODE ED-10584
|
|
17
|
+
|
|
18
|
+
if (queueAnalytics) {
|
|
19
|
+
var queue = AnalyticsQueue.get();
|
|
20
|
+
queue.schedule(function () {
|
|
21
|
+
var _createAnalyticsEvent;
|
|
22
|
+
return (_createAnalyticsEvent = createAnalyticsEvent(payload)) === null || _createAnalyticsEvent === void 0 ? void 0 : _createAnalyticsEvent.fire(channel);
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
var _createAnalyticsEvent2;
|
|
26
|
+
(_createAnalyticsEvent2 = createAnalyticsEvent(payload)) === null || _createAnalyticsEvent2 === void 0 ? void 0 : _createAnalyticsEvent2.fire(channel);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, BROWSER_FREEZE_INTERACTION_TYPE, CONTENT_COMPONENT, DELETE_DIRECTION, EVENT_TYPE, FLOATING_CONTROLS_TITLE, FULL_WIDTH_MODE, GAP_CURSOR_POSITION, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, LAYOUT_TYPE, LINK_REPRESENTATION, LINK_RESOURCE, LINK_STATUS, LIST_TEXT_SCENARIOS, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST, OUTDENT_SCENARIOS, MODE, PLATFORMS, PUNC, PasteContents, PasteSources, PasteTypes, RESOLVE_METHOD, SELECTION_TYPE, SELECTION_POSITION, SMART_LINK_TYPE, SYMBOL, SmartLinkNodeContexts, TABLE_ACTION, TABLE_BREAKOUT, TARGET_SELECTION_SOURCE, TOOLBAR_ACTION_SUBJECT_ID, TRIGGER_METHOD, USER_CONTEXT } from './types';
|
|
1
|
+
export { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, BROWSER_FREEZE_INTERACTION_TYPE, CONTENT_COMPONENT, DELETE_DIRECTION, EVENT_TYPE, FLOATING_CONTROLS_TITLE, FULL_WIDTH_MODE, GAP_CURSOR_POSITION, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, LAYOUT_TYPE, LINK_REPRESENTATION, LINK_RESOURCE, LINK_STATUS, LIST_TEXT_SCENARIOS, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST, OUTDENT_SCENARIOS, MODE, PLATFORMS, PUNC, PasteContents, PasteSources, PasteTypes, RESOLVE_METHOD, SELECTION_TYPE, SELECTION_POSITION, SMART_LINK_TYPE, SYMBOL, SmartLinkNodeContexts, TABLE_ACTION, TABLE_BREAKOUT, TARGET_SELECTION_SOURCE, TOOLBAR_ACTION_SUBJECT_ID, TRIGGER_METHOD, USER_CONTEXT } from './types';
|
|
2
|
+
export { fireAnalyticsEvent } from './fire-analytics-event';
|
|
3
|
+
export { getAnalyticsEventsFromTransaction } from './utils';
|
|
@@ -57,6 +57,10 @@ export var ACTION;
|
|
|
57
57
|
ACTION["INITIALISED_FRAGMENT_MARK"] = "initialisedFragmentMark";
|
|
58
58
|
ACTION["INPUT_PERF_SAMPLING"] = "inputPerfSampling";
|
|
59
59
|
ACTION["INPUT_PERF_SAMPLING_AVG"] = "inputPerfSamplingAvg";
|
|
60
|
+
ACTION["INPUT_PERF_SAMPLING_SINGLE_KEYPRESS"] = "inputPerfSamplingSingleKeypress";
|
|
61
|
+
ACTION["INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG"] = "inputPerfSamplingSingleKeypressAvg";
|
|
62
|
+
ACTION["INPUT_PERF_SAMPLING_RENDERED"] = "inputPerfSamplingRendered";
|
|
63
|
+
ACTION["INPUT_PERF_SAMPLING_RENDERED_AVG"] = "inputPerfSamplingRenderedAvg";
|
|
60
64
|
ACTION["INSERTED"] = "inserted";
|
|
61
65
|
ACTION["INVALID_DOCUMENT_ENCOUNTERED"] = "invalidDocumentEncountered";
|
|
62
66
|
ACTION["INVOKED"] = "invoked";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
3
|
+
export function getAnalyticsEventsFromTransaction(tr) {
|
|
4
|
+
return tr.steps.filter(function (step) {
|
|
5
|
+
return step instanceof AnalyticsStep;
|
|
6
|
+
}).reduce(function (acc, step) {
|
|
7
|
+
return [].concat(_toConsumableArray(acc), _toConsumableArray(step.analyticsEvents));
|
|
8
|
+
}, []);
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Hook to run code once in a functional component.
|
|
6
|
+
* Emulates the behaviour of a `constructor` in a class component
|
|
7
|
+
* Place this at the top of your functional component so that it is run first.
|
|
8
|
+
*
|
|
9
|
+
* @param callback Callback function to run once
|
|
10
|
+
*/
|
|
11
|
+
export default function useConstructor(callback) {
|
|
12
|
+
var hasRun = useRef(false);
|
|
13
|
+
if (!hasRun.current) {
|
|
14
|
+
callback();
|
|
15
|
+
hasRun.current = true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Can be used to get the previous state of a prop.
|
|
6
|
+
* This can be helpful when converting class components to functional
|
|
7
|
+
* where we don't have the `prevProps`.
|
|
8
|
+
*
|
|
9
|
+
* @param value New state of the
|
|
10
|
+
* @param initialValue Optional parameter for the inital state of the component
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export default function usePreviousState(value, initialValue) {
|
|
14
|
+
var ref = useRef(initialValue);
|
|
15
|
+
var prevValue = ref.current;
|
|
16
|
+
ref.current = value;
|
|
17
|
+
return prevValue;
|
|
18
|
+
}
|
|
@@ -26,7 +26,7 @@ export var toggleHeading6 = makeKeyMapWithCommon('Heading 6', 'Mod-Alt-6');
|
|
|
26
26
|
export var toggleOrderedList = makeKeyMapWithCommon('Numbered list', 'Mod-Shift-7');
|
|
27
27
|
export var ctrlBackSpace = makeKeyMapWithCommon('Cmd + Backspace', 'Mod-Backspace');
|
|
28
28
|
export var toggleBulletList = makeKeyMapWithCommon('Bullet list', 'Mod-Shift-8');
|
|
29
|
-
export var toggleBlockQuote =
|
|
29
|
+
export var toggleBlockQuote = makeKeyMapWithCommon('Quote', 'Mod-Shift-9');
|
|
30
30
|
export var insertNewLine = makeKeyMapWithCommon('Insert new line', 'Shift-Enter');
|
|
31
31
|
export var shiftBackspace = makeKeyMapWithCommon('Shift Backspace', 'Shift-Backspace');
|
|
32
32
|
export var splitCodeBlock = makeKeyMapWithCommon('Split code block', 'Enter');
|
package/dist/esm/styles/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { textColorStyles } from './shared/text-color';
|
|
2
|
-
export { tableSharedStyle, tableMarginTop, tableMarginBottom, tableMarginSides, tableCellMinWidth, tableNewColumnMinWidth, tableCellBorderWidth, calcTableWidth, TableSharedCssClassName, tableResizeHandleWidth, tableCellPadding } from './shared/table';
|
|
2
|
+
export { tableSharedStyle, tableMarginTop, tableMarginBottom, tableMarginSides, tableCellMinWidth, tableNewColumnMinWidth, tableCellBorderWidth, calcTableWidth, TableSharedCssClassName, tableResizeHandleWidth, tableCellPadding, tableMarginTopWithControl } from './shared/table';
|
|
3
3
|
export { AnnotationSharedClassNames, AnnotationSharedCSSByState, annotationSharedStyles } from './shared/annotation';
|
|
4
4
|
export { columnLayoutSharedStyle } from './shared/column-layout';
|
|
5
5
|
export { mediaSingleSharedStyle, richMediaClassName } from './shared/media-single';
|
|
@@ -12,6 +12,7 @@ import browser from '../../utils/browser';
|
|
|
12
12
|
import { CodeBlockSharedCssClassName } from './code-block';
|
|
13
13
|
export var tableMarginTop = 24;
|
|
14
14
|
export var tableMarginBottom = 16;
|
|
15
|
+
export var tableMarginTopWithControl = 14;
|
|
15
16
|
export var tableMarginSides = 8;
|
|
16
17
|
export var tableCellMinWidth = 48;
|
|
17
18
|
export var tableNewColumnMinWidth = 140;
|
|
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
18
18
|
import { borderRadius, gridSize } from '@atlaskit/theme/constants';
|
|
19
19
|
import Layer from '../Layer';
|
|
20
20
|
var packageName = "@atlaskit/editor-common";
|
|
21
|
-
var packageVersion = "72.
|
|
21
|
+
var packageVersion = "72.5.1";
|
|
22
22
|
var halfFocusRing = 1;
|
|
23
23
|
var dropOffset = "0, ".concat(gridSize(), "px");
|
|
24
24
|
var DropList = /*#__PURE__*/function (_Component) {
|
package/dist/esm/ui/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { default as UnsupportedBlock } from './UnsupportedBlock';
|
|
|
8
8
|
export { default as UnsupportedInline } from './UnsupportedInline';
|
|
9
9
|
export { BaseTheme, mapBreakpointToLayoutMaxWidth } from './BaseTheme';
|
|
10
10
|
export { default as withOuterListeners } from './with-outer-listeners';
|
|
11
|
-
export { WidthConsumer, WidthProvider, getBreakpoint } from './WidthProvider';
|
|
11
|
+
export { WidthContext, WidthConsumer, WidthProvider, getBreakpoint } from './WidthProvider';
|
|
12
12
|
export { default as overflowShadow, shadowClassNames } from './OverflowShadow';
|
|
13
13
|
export { shadowObserverClassNames, ShadowObserver } from './OverflowShadow/shadowObserver';
|
|
14
14
|
export { WithCreateAnalyticsEvent } from './WithCreateAnalyticsEvent';
|
|
@@ -10,7 +10,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
10
10
|
/** @jsx jsx */
|
|
11
11
|
import React, { PureComponent } from 'react';
|
|
12
12
|
import { jsx } from '@emotion/react';
|
|
13
|
-
import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
|
|
14
13
|
import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
|
|
15
14
|
import { N0 } from '@atlaskit/theme/colors';
|
|
16
15
|
import Tooltip from '@atlaskit/tooltip';
|
|
@@ -50,8 +49,8 @@ var Color = /*#__PURE__*/function (_PureComponent) {
|
|
|
50
49
|
borderColor = _this$props2.borderColor,
|
|
51
50
|
_this$props2$checkMar = _this$props2.checkMarkColor,
|
|
52
51
|
checkMarkColor = _this$props2$checkMar === void 0 ? N0 : _this$props2$checkMar,
|
|
53
|
-
|
|
54
|
-
var colorStyle =
|
|
52
|
+
hexToPaletteColor = _this$props2.hexToPaletteColor;
|
|
53
|
+
var colorStyle = hexToPaletteColor ? hexToPaletteColor(value) : value;
|
|
55
54
|
return jsx(Tooltip, {
|
|
56
55
|
content: label
|
|
57
56
|
}, jsx("span", {
|
|
@@ -73,7 +73,7 @@ export var panelBackgroundPalette = [{
|
|
|
73
73
|
value: colors.P100
|
|
74
74
|
}].map(function (color) {
|
|
75
75
|
return _objectSpread(_objectSpread({}, color), {}, {
|
|
76
|
-
border: DEFAULT_BORDER_COLOR
|
|
76
|
+
border: "var(--ds-border, ".concat(DEFAULT_BORDER_COLOR, ")")
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
@@ -9,6 +9,7 @@ import Color from './Color';
|
|
|
9
9
|
import getColorMessage from './Palettes/getColorMessage';
|
|
10
10
|
import { newDarkPalette, newLightPalette } from './Palettes/paletteMessagesTokenModeNames';
|
|
11
11
|
import { colorPaletteWrapper } from './styles';
|
|
12
|
+
import { DEFAULT_COLOR_PICKER_COLUMNS, getColorsPerRowFromPalette } from './utils';
|
|
12
13
|
/**
|
|
13
14
|
* For a given color pick the color from a list of colors with
|
|
14
15
|
* the highest contrast
|
|
@@ -16,12 +17,12 @@ import { colorPaletteWrapper } from './styles';
|
|
|
16
17
|
* @param color color string, suppports HEX, RGB, RGBA etc.
|
|
17
18
|
* @return Highest contrast color in pool
|
|
18
19
|
*/
|
|
19
|
-
function getCheckMarkColor(color,
|
|
20
|
+
function getCheckMarkColor(color, useIconToken) {
|
|
20
21
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
21
22
|
var contrastColor = [N0, N500].sort(function (a, b) {
|
|
22
23
|
return chromatism.difference(b, color) - chromatism.difference(a, color);
|
|
23
24
|
})[0];
|
|
24
|
-
if (!
|
|
25
|
+
if (!useIconToken) {
|
|
25
26
|
return contrastColor;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -34,24 +35,21 @@ function getCheckMarkColor(color, textPalette) {
|
|
|
34
35
|
var ColorPalette = function ColorPalette(props) {
|
|
35
36
|
var palette = props.palette,
|
|
36
37
|
_props$cols = props.cols,
|
|
37
|
-
cols = _props$cols === void 0 ?
|
|
38
|
+
cols = _props$cols === void 0 ? DEFAULT_COLOR_PICKER_COLUMNS : _props$cols,
|
|
38
39
|
onClick = props.onClick,
|
|
39
40
|
selectedColor = props.selectedColor,
|
|
40
41
|
className = props.className,
|
|
41
42
|
formatMessage = props.intl.formatMessage,
|
|
42
43
|
_props$textPalette = props.textPalette,
|
|
43
44
|
textPalette = _props$textPalette === void 0 ? false : _props$textPalette,
|
|
45
|
+
hexToPaletteColor = props.hexToPaletteColor,
|
|
44
46
|
_props$useSomewhatSem = props.useSomewhatSemanticTextColorNames,
|
|
45
47
|
useSomewhatSemanticTextColorNames = _props$useSomewhatSem === void 0 ? false : _props$useSomewhatSem;
|
|
46
48
|
var _useThemeObserver = useThemeObserver(),
|
|
47
49
|
tokenTheme = _useThemeObserver.colorMode;
|
|
50
|
+
var useIconToken = !!hexToPaletteColor;
|
|
48
51
|
var colorsPerRow = React.useMemo(function () {
|
|
49
|
-
return palette
|
|
50
|
-
var chunkIndex = Math.floor(index / cols);
|
|
51
|
-
resultArray[chunkIndex] = resultArray[chunkIndex] || []; // start a new chunk
|
|
52
|
-
resultArray[chunkIndex].push(item);
|
|
53
|
-
return resultArray;
|
|
54
|
-
}, []);
|
|
52
|
+
return getColorsPerRowFromPalette(palette, cols);
|
|
55
53
|
}, [palette, cols]);
|
|
56
54
|
return jsx(React.Fragment, null, colorsPerRow.map(function (row, rowIdx) {
|
|
57
55
|
return jsx("div", {
|
|
@@ -79,8 +77,8 @@ var ColorPalette = function ColorPalette(props) {
|
|
|
79
77
|
label: message ? formatMessage(message) : label,
|
|
80
78
|
onClick: onClick,
|
|
81
79
|
isSelected: value === selectedColor,
|
|
82
|
-
checkMarkColor: getCheckMarkColor(value,
|
|
83
|
-
|
|
80
|
+
checkMarkColor: getCheckMarkColor(value, useIconToken),
|
|
81
|
+
hexToPaletteColor: hexToPaletteColor
|
|
84
82
|
});
|
|
85
83
|
}));
|
|
86
84
|
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export var DEFAULT_COLOR_PICKER_COLUMNS = 7;
|
|
2
|
+
export function getColorsPerRowFromPalette(palette) {
|
|
3
|
+
var cols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_COLOR_PICKER_COLUMNS;
|
|
4
|
+
return palette.reduce(function (resultArray, item, index) {
|
|
5
|
+
var chunkIndex = Math.floor(index / cols);
|
|
6
|
+
resultArray[chunkIndex] = resultArray[chunkIndex] || []; // start a new chunk
|
|
7
|
+
resultArray[chunkIndex].push(item);
|
|
8
|
+
return resultArray;
|
|
9
|
+
}, []);
|
|
10
|
+
}
|
|
11
|
+
export function getSelectedRowAndColumn(colorsPerRow, selectedColor) {
|
|
12
|
+
var selectedRowIndex = -1;
|
|
13
|
+
var selectedColumnIndex = -1;
|
|
14
|
+
colorsPerRow.forEach(function (row, rowIndex) {
|
|
15
|
+
row.forEach(function (_ref, columnIndex) {
|
|
16
|
+
var value = _ref.value;
|
|
17
|
+
if (value === selectedColor) {
|
|
18
|
+
selectedRowIndex = rowIndex;
|
|
19
|
+
selectedColumnIndex = columnIndex;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
selectedRowIndex: selectedRowIndex,
|
|
25
|
+
selectedColumnIndex: selectedColumnIndex
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function getSelectedRowAndColumnFromPalette(palette, selectedColor) {
|
|
29
|
+
var cols = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_COLOR_PICKER_COLUMNS;
|
|
30
|
+
var colorsPerRow = getColorsPerRowFromPalette(palette, cols);
|
|
31
|
+
return getSelectedRowAndColumn(colorsPerRow, selectedColor);
|
|
32
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as ColorPalette } from './ColorPalette';
|
|
2
2
|
export { default as Color } from './ColorPalette/Color';
|
|
3
|
+
export { DEFAULT_COLOR_PICKER_COLUMNS, getColorsPerRowFromPalette, getSelectedRowAndColumn, getSelectedRowAndColumnFromPalette } from './ColorPalette/utils';
|
|
3
4
|
export { default as cellBackgroundColorPalette } from './ColorPalette/Palettes/cellBackgroundColorPalette';
|
|
4
5
|
export { default as colorPaletteMessages } from './ColorPalette/Palettes/paletteMessages';
|
|
5
6
|
export { panelBackgroundPalette, panelDarkModeBackgroundPalette } from './ColorPalette/Palettes/panelBackgroundPalette';
|
package/dist/esm/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React, { useLayoutEffect, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* This component is a wrapper for color picker which listens to keydown events of children
|
|
4
|
+
* and handles arrow key navigation
|
|
5
|
+
*/
|
|
6
|
+
export var ColorPaletteArrowKeyNavigationProvider = function ColorPaletteArrowKeyNavigationProvider(_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
selectedRowIndex = _ref.selectedRowIndex,
|
|
9
|
+
selectedColumnIndex = _ref.selectedColumnIndex,
|
|
10
|
+
isOpenedByKeyboard = _ref.isOpenedByKeyboard,
|
|
11
|
+
isPopupPositioned = _ref.isPopupPositioned,
|
|
12
|
+
handleClose = _ref.handleClose,
|
|
13
|
+
closeOnTab = _ref.closeOnTab;
|
|
14
|
+
var wrapperRef = useRef(null);
|
|
15
|
+
var currentSelectedColumnIndex = useRef(selectedColumnIndex === -1 ? 0 : selectedColumnIndex);
|
|
16
|
+
var currentSelectedRowIndex = useRef(selectedRowIndex === -1 ? 0 : selectedRowIndex);
|
|
17
|
+
var incrementRowIndex = function incrementRowIndex(rowElements, columnElements) {
|
|
18
|
+
if (currentSelectedRowIndex.current === rowElements.length - 1) {
|
|
19
|
+
currentSelectedRowIndex.current = 0;
|
|
20
|
+
} else {
|
|
21
|
+
currentSelectedRowIndex.current = currentSelectedRowIndex.current + 1;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var decrementRowIndex = function decrementRowIndex(rowElements, columnElements) {
|
|
25
|
+
if (currentSelectedRowIndex.current === 0) {
|
|
26
|
+
currentSelectedRowIndex.current = rowElements.length - 1;
|
|
27
|
+
} else {
|
|
28
|
+
currentSelectedRowIndex.current = currentSelectedRowIndex.current - 1;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
useLayoutEffect(function () {
|
|
32
|
+
var incrementColumnIndex = function incrementColumnIndex(rowElements, columnElements) {
|
|
33
|
+
if (currentSelectedColumnIndex.current === columnElements.length - 1) {
|
|
34
|
+
incrementRowIndex(rowElements, columnElements);
|
|
35
|
+
currentSelectedColumnIndex.current = 0;
|
|
36
|
+
} else {
|
|
37
|
+
currentSelectedColumnIndex.current = currentSelectedColumnIndex.current + 1;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var decrementColumnIndex = function decrementColumnIndex(rowElements, columnElements) {
|
|
41
|
+
if (currentSelectedColumnIndex.current === 0) {
|
|
42
|
+
decrementRowIndex(rowElements, columnElements);
|
|
43
|
+
currentSelectedColumnIndex.current = columnElements.length - 1;
|
|
44
|
+
} else {
|
|
45
|
+
currentSelectedColumnIndex.current = currentSelectedColumnIndex.current - 1;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var focusColorSwatch = function focusColorSwatch() {
|
|
49
|
+
var _focusableElements$cu;
|
|
50
|
+
var colorSwatchesRowElements = getColorSwatchesRows(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
51
|
+
var currentSelectedColorSwatchRowElement = colorSwatchesRowElements[currentSelectedRowIndex.current];
|
|
52
|
+
var focusableElements = getFocusableElements(currentSelectedColorSwatchRowElement);
|
|
53
|
+
if (!focusableElements || (focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.length) === 0) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
(_focusableElements$cu = focusableElements[currentSelectedColumnIndex.current]) === null || _focusableElements$cu === void 0 ? void 0 : _focusableElements$cu.focus();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* To handle the key events on the list
|
|
61
|
+
* @param event
|
|
62
|
+
*/
|
|
63
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
64
|
+
if (event.key === 'Tab' && closeOnTab) {
|
|
65
|
+
handleClose(event);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
var colorSwatchesRowElements = getColorSwatchesRows(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
69
|
+
var currentSelectedColorSwatchRowElement = colorSwatchesRowElements[currentSelectedRowIndex.current];
|
|
70
|
+
var focusableElements = getFocusableElements(currentSelectedColorSwatchRowElement);
|
|
71
|
+
switch (event.key) {
|
|
72
|
+
case 'ArrowDown':
|
|
73
|
+
incrementRowIndex(colorSwatchesRowElements, focusableElements);
|
|
74
|
+
focusColorSwatch();
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
break;
|
|
77
|
+
case 'ArrowUp':
|
|
78
|
+
decrementRowIndex(colorSwatchesRowElements, focusableElements);
|
|
79
|
+
focusColorSwatch();
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
break;
|
|
82
|
+
case 'ArrowLeft':
|
|
83
|
+
decrementColumnIndex(colorSwatchesRowElements, focusableElements);
|
|
84
|
+
focusColorSwatch();
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
break;
|
|
87
|
+
case 'ArrowRight':
|
|
88
|
+
incrementColumnIndex(colorSwatchesRowElements, focusableElements);
|
|
89
|
+
focusColorSwatch();
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
break;
|
|
92
|
+
case 'Escape':
|
|
93
|
+
handleClose(event);
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
100
|
+
// set focus to current selected color swatch if only opened by keyboard
|
|
101
|
+
if (isOpenedByKeyboard && isPopupPositioned) {
|
|
102
|
+
// Using timeout because, we need to wait till color palette is rendered
|
|
103
|
+
// and visible on screen, then only focus color swatch, otherwise focus will be
|
|
104
|
+
// moved to body
|
|
105
|
+
setTimeout(function () {
|
|
106
|
+
focusColorSwatch();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return function () {
|
|
110
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
111
|
+
};
|
|
112
|
+
}, [currentSelectedColumnIndex, isOpenedByKeyboard, isPopupPositioned, wrapperRef, handleClose, closeOnTab]);
|
|
113
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
114
|
+
className: "custom-key-handler-wrapper",
|
|
115
|
+
ref: wrapperRef
|
|
116
|
+
}, children);
|
|
117
|
+
};
|
|
118
|
+
function getColorSwatchesRows(rootNode) {
|
|
119
|
+
if (!rootNode) {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
var colorSwatchesRowElements = rootNode.querySelectorAll('div[role=radiogroup]') || [];
|
|
123
|
+
return Array.from(colorSwatchesRowElements);
|
|
124
|
+
}
|
|
125
|
+
function getFocusableElements(rootNode) {
|
|
126
|
+
if (!rootNode) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
var focusableModalElements = rootNode.querySelectorAll('button[role=radio]:not([disabled])') || [];
|
|
130
|
+
return Array.from(focusableModalElements);
|
|
131
|
+
}
|