@atlaskit/editor-toolbar 0.8.7 → 0.9.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 +11 -0
- package/dist/cjs/hooks/ui-context.js +6 -3
- package/dist/cjs/ui/Toolbar.js +7 -2
- package/dist/cjs/ui/ToolbarDropdownMenu.js +1 -1
- package/dist/cjs/ui/ToolbarNestedDropdownMenu.js +6 -2
- package/dist/cjs/ui/ViewEventEmitter.js +33 -0
- package/dist/es2019/hooks/ui-context.js +6 -3
- package/dist/es2019/ui/Toolbar.js +7 -2
- package/dist/es2019/ui/ToolbarDropdownMenu.js +1 -1
- package/dist/es2019/ui/ToolbarNestedDropdownMenu.js +6 -2
- package/dist/es2019/ui/ViewEventEmitter.js +29 -0
- package/dist/esm/hooks/ui-context.js +6 -3
- package/dist/esm/ui/Toolbar.js +7 -2
- package/dist/esm/ui/ToolbarDropdownMenu.js +1 -1
- package/dist/esm/ui/ToolbarNestedDropdownMenu.js +6 -2
- package/dist/esm/ui/ViewEventEmitter.js +27 -0
- package/dist/types/hooks/ui-context.d.ts +9 -1
- package/dist/types/ui/Toolbar.d.ts +3 -2
- package/dist/types/ui/ToolbarDropdownMenu.d.ts +1 -1
- package/dist/types/ui/ToolbarNestedDropdownMenu.d.ts +2 -1
- package/dist/types/ui/ToolbarTooltip.d.ts +1 -1
- package/dist/types/ui/ViewEventEmitter.d.ts +12 -0
- package/dist/types-ts4.5/hooks/ui-context.d.ts +9 -1
- package/dist/types-ts4.5/ui/Toolbar.d.ts +3 -2
- package/dist/types-ts4.5/ui/ToolbarDropdownMenu.d.ts +1 -1
- package/dist/types-ts4.5/ui/ToolbarNestedDropdownMenu.d.ts +2 -1
- package/dist/types-ts4.5/ui/ToolbarTooltip.d.ts +1 -1
- package/dist/types-ts4.5/ui/ViewEventEmitter.d.ts +12 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-toolbar
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`553afc302139b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/553afc302139b) -
|
|
8
|
+
Add analytic emitter component which fires an event when dropdowns are viewed
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 0.8.7
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -11,7 +11,8 @@ var ToolbarUIContext = /*#__PURE__*/(0, _react.createContext)({
|
|
|
11
11
|
onDropdownOpenChanged: function onDropdownOpenChanged() {},
|
|
12
12
|
preventDefaultOnMouseDown: false,
|
|
13
13
|
isDisabled: false,
|
|
14
|
-
popupsMountPoint: undefined
|
|
14
|
+
popupsMountPoint: undefined,
|
|
15
|
+
fireAnalyticsEvent: undefined
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -31,7 +32,8 @@ var ToolbarUIProvider = exports.ToolbarUIProvider = function ToolbarUIProvider(_
|
|
|
31
32
|
isDisabled = _ref.isDisabled,
|
|
32
33
|
popupsMountPoint = _ref.popupsMountPoint,
|
|
33
34
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
34
|
-
popupsScrollableElement = _ref.popupsScrollableElement
|
|
35
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
36
|
+
fireAnalyticsEvent = _ref.fireAnalyticsEvent;
|
|
35
37
|
return /*#__PURE__*/_react.default.createElement(ToolbarUIContext.Provider, {
|
|
36
38
|
value: {
|
|
37
39
|
onDropdownOpenChanged: onDropdownOpenChanged,
|
|
@@ -39,7 +41,8 @@ var ToolbarUIProvider = exports.ToolbarUIProvider = function ToolbarUIProvider(_
|
|
|
39
41
|
isDisabled: isDisabled,
|
|
40
42
|
popupsMountPoint: popupsMountPoint,
|
|
41
43
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
42
|
-
popupsScrollableElement: popupsScrollableElement
|
|
44
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
45
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
43
46
|
}
|
|
44
47
|
}, children);
|
|
45
48
|
};
|
package/dist/cjs/ui/Toolbar.js
CHANGED
|
@@ -15,6 +15,7 @@ var _css = require("@atlaskit/css");
|
|
|
15
15
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
16
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
17
|
var _ResponsiveContainer = require("./ResponsiveContainer");
|
|
18
|
+
var _ViewEventEmitter = require("./ViewEventEmitter");
|
|
18
19
|
var styles = {
|
|
19
20
|
toolbarBase: "_2rko1qi0 _zulp1b66 _1e0c1txw _4cvr1h6o",
|
|
20
21
|
toolbar: "_bfhk1bhr _4t3i14no _u5f31b66 _19bv1b66 _16qs1cd0",
|
|
@@ -29,13 +30,17 @@ var styles = {
|
|
|
29
30
|
*/
|
|
30
31
|
var Toolbar = exports.Toolbar = function Toolbar(_ref) {
|
|
31
32
|
var children = _ref.children,
|
|
32
|
-
label = _ref.label
|
|
33
|
+
label = _ref.label,
|
|
34
|
+
actionSubjectId = _ref.actionSubjectId;
|
|
33
35
|
var isResponsiveEnabled = (0, _expValEquals.expValEquals)('platform_editor_aifc_selection_toolbar_responsive', 'isEnabled', true);
|
|
34
36
|
var toolbar = /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
35
37
|
xcss: (0, _css.cx)(styles.toolbarBase, styles.toolbar, isResponsiveEnabled && styles.toolbarResponsive, (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) && styles.hiddenSelectors),
|
|
36
38
|
role: "toolbar",
|
|
37
39
|
"aria-label": label
|
|
38
|
-
},
|
|
40
|
+
}, (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_toolbar_analytic', 'isEnabled', true) ? /*#__PURE__*/_react.default.createElement(_ViewEventEmitter.ViewEventEmitter, {
|
|
41
|
+
actionSubject: _ViewEventEmitter.ACTION_SUBJECT.TOOLBAR,
|
|
42
|
+
actionSubjectId: actionSubjectId
|
|
43
|
+
}) : null, children);
|
|
39
44
|
if (isResponsiveEnabled) {
|
|
40
45
|
return /*#__PURE__*/_react.default.createElement(_ResponsiveContainer.ResponsiveWrapper, null, toolbar);
|
|
41
46
|
} else {
|
|
@@ -56,9 +56,9 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
|
56
56
|
"aria-controls": triggerProps['aria-controls'],
|
|
57
57
|
onBlur: triggerProps.onBlur,
|
|
58
58
|
onClick: function onClick(e) {
|
|
59
|
+
_onClick && _onClick(e, !(menuContext !== null && menuContext !== void 0 && menuContext.isOpen));
|
|
59
60
|
handleClick();
|
|
60
61
|
triggerProps.onClick && triggerProps.onClick(e);
|
|
61
|
-
_onClick && _onClick(e);
|
|
62
62
|
},
|
|
63
63
|
onFocus: triggerProps.onFocus,
|
|
64
64
|
testId: testId,
|
|
@@ -27,7 +27,8 @@ var ToolbarNestedDropdownMenu = exports.ToolbarNestedDropdownMenu = function Too
|
|
|
27
27
|
isDisabled = _ref.isDisabled,
|
|
28
28
|
testId = _ref.testId,
|
|
29
29
|
_ref$enableMaxHeight = _ref.enableMaxHeight,
|
|
30
|
-
enableMaxHeight = _ref$enableMaxHeight === void 0 ? false : _ref$enableMaxHeight
|
|
30
|
+
enableMaxHeight = _ref$enableMaxHeight === void 0 ? false : _ref$enableMaxHeight,
|
|
31
|
+
_onClick = _ref.onClick;
|
|
31
32
|
return /*#__PURE__*/React.createElement(_dropdownMenu.default, {
|
|
32
33
|
placement: "right-start",
|
|
33
34
|
trigger: function trigger(triggerProps) {
|
|
@@ -35,7 +36,10 @@ var ToolbarNestedDropdownMenu = exports.ToolbarNestedDropdownMenu = function Too
|
|
|
35
36
|
elemBefore: elemBefore,
|
|
36
37
|
elemAfter: elemAfter,
|
|
37
38
|
isSelected: triggerProps.isSelected,
|
|
38
|
-
onClick:
|
|
39
|
+
onClick: function onClick(e) {
|
|
40
|
+
_onClick && _onClick(e);
|
|
41
|
+
triggerProps.onClick && triggerProps.onClick(e);
|
|
42
|
+
},
|
|
39
43
|
testId: testId,
|
|
40
44
|
triggerRef: triggerProps.triggerRef,
|
|
41
45
|
hasNestedDropdownMenu: true,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ViewEventEmitter = exports.ACTION_SUBJECT = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _uiContext = require("../hooks/ui-context");
|
|
9
|
+
var ACTION_SUBJECT = exports.ACTION_SUBJECT = {
|
|
10
|
+
TOOLBAR: 'toolbar',
|
|
11
|
+
TOOLBAR_DROPDOWN_MENU: 'toolbarDropdownMenu'
|
|
12
|
+
};
|
|
13
|
+
var ViewEventEmitter = exports.ViewEventEmitter = function ViewEventEmitter(_ref) {
|
|
14
|
+
var actionSubjectId = _ref.actionSubjectId,
|
|
15
|
+
actionSubject = _ref.actionSubject;
|
|
16
|
+
var isMountedRef = (0, _react.useRef)(false);
|
|
17
|
+
var _useToolbarUI = (0, _uiContext.useToolbarUI)(),
|
|
18
|
+
fireAnalyticsEvent = _useToolbarUI.fireAnalyticsEvent;
|
|
19
|
+
(0, _react.useEffect)(function () {
|
|
20
|
+
if (isMountedRef.current) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
isMountedRef.current = true;
|
|
24
|
+
var payload = {
|
|
25
|
+
action: 'viewed',
|
|
26
|
+
actionSubject: actionSubject,
|
|
27
|
+
actionSubjectId: actionSubjectId,
|
|
28
|
+
eventType: 'ui'
|
|
29
|
+
};
|
|
30
|
+
fireAnalyticsEvent && fireAnalyticsEvent(payload);
|
|
31
|
+
}, [actionSubjectId, actionSubject, fireAnalyticsEvent]);
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
@@ -3,7 +3,8 @@ const ToolbarUIContext = /*#__PURE__*/createContext({
|
|
|
3
3
|
onDropdownOpenChanged: () => {},
|
|
4
4
|
preventDefaultOnMouseDown: false,
|
|
5
5
|
isDisabled: false,
|
|
6
|
-
popupsMountPoint: undefined
|
|
6
|
+
popupsMountPoint: undefined,
|
|
7
|
+
fireAnalyticsEvent: undefined
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -23,7 +24,8 @@ export const ToolbarUIProvider = ({
|
|
|
23
24
|
isDisabled,
|
|
24
25
|
popupsMountPoint,
|
|
25
26
|
popupsBoundariesElement,
|
|
26
|
-
popupsScrollableElement
|
|
27
|
+
popupsScrollableElement,
|
|
28
|
+
fireAnalyticsEvent
|
|
27
29
|
}) => {
|
|
28
30
|
return /*#__PURE__*/React.createElement(ToolbarUIContext.Provider, {
|
|
29
31
|
value: {
|
|
@@ -32,7 +34,8 @@ export const ToolbarUIProvider = ({
|
|
|
32
34
|
isDisabled,
|
|
33
35
|
popupsMountPoint,
|
|
34
36
|
popupsBoundariesElement,
|
|
35
|
-
popupsScrollableElement
|
|
37
|
+
popupsScrollableElement,
|
|
38
|
+
fireAnalyticsEvent
|
|
36
39
|
}
|
|
37
40
|
}, children);
|
|
38
41
|
};
|
|
@@ -8,6 +8,7 @@ import { cx } from '@atlaskit/css';
|
|
|
8
8
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
9
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
10
|
import { ResponsiveContainer, ResponsiveWrapper } from './ResponsiveContainer';
|
|
11
|
+
import { ACTION_SUBJECT, ViewEventEmitter } from './ViewEventEmitter';
|
|
11
12
|
const styles = {
|
|
12
13
|
toolbarBase: "_2rko1qi0 _zulp1b66 _1e0c1txw _4cvr1h6o",
|
|
13
14
|
toolbar: "_bfhk1bhr _4t3i14no _u5f31b66 _19bv1b66 _16qs1cd0",
|
|
@@ -22,14 +23,18 @@ const styles = {
|
|
|
22
23
|
*/
|
|
23
24
|
export const Toolbar = ({
|
|
24
25
|
children,
|
|
25
|
-
label
|
|
26
|
+
label,
|
|
27
|
+
actionSubjectId
|
|
26
28
|
}) => {
|
|
27
29
|
const isResponsiveEnabled = expValEquals('platform_editor_aifc_selection_toolbar_responsive', 'isEnabled', true);
|
|
28
30
|
const toolbar = /*#__PURE__*/React.createElement(Box, {
|
|
29
31
|
xcss: cx(styles.toolbarBase, styles.toolbar, isResponsiveEnabled && styles.toolbarResponsive, expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) && styles.hiddenSelectors),
|
|
30
32
|
role: "toolbar",
|
|
31
33
|
"aria-label": label
|
|
32
|
-
},
|
|
34
|
+
}, expValEquals('platform_editor_toolbar_aifc_toolbar_analytic', 'isEnabled', true) ? /*#__PURE__*/React.createElement(ViewEventEmitter, {
|
|
35
|
+
actionSubject: ACTION_SUBJECT.TOOLBAR,
|
|
36
|
+
actionSubjectId: actionSubjectId
|
|
37
|
+
}) : null, children);
|
|
33
38
|
if (isResponsiveEnabled) {
|
|
34
39
|
return /*#__PURE__*/React.createElement(ResponsiveWrapper, null, toolbar);
|
|
35
40
|
} else {
|
|
@@ -48,9 +48,9 @@ const ToolbarDropdownMenuContent = ({
|
|
|
48
48
|
"aria-controls": triggerProps['aria-controls'],
|
|
49
49
|
onBlur: triggerProps.onBlur,
|
|
50
50
|
onClick: e => {
|
|
51
|
+
onClick && onClick(e, !(menuContext !== null && menuContext !== void 0 && menuContext.isOpen));
|
|
51
52
|
handleClick();
|
|
52
53
|
triggerProps.onClick && triggerProps.onClick(e);
|
|
53
|
-
onClick && onClick(e);
|
|
54
54
|
},
|
|
55
55
|
onFocus: triggerProps.onFocus,
|
|
56
56
|
testId: testId,
|
|
@@ -17,7 +17,8 @@ export const ToolbarNestedDropdownMenu = ({
|
|
|
17
17
|
children,
|
|
18
18
|
isDisabled,
|
|
19
19
|
testId,
|
|
20
|
-
enableMaxHeight = false
|
|
20
|
+
enableMaxHeight = false,
|
|
21
|
+
onClick
|
|
21
22
|
}) => {
|
|
22
23
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
23
24
|
placement: "right-start",
|
|
@@ -25,7 +26,10 @@ export const ToolbarNestedDropdownMenu = ({
|
|
|
25
26
|
elemBefore: elemBefore,
|
|
26
27
|
elemAfter: elemAfter,
|
|
27
28
|
isSelected: triggerProps.isSelected,
|
|
28
|
-
onClick:
|
|
29
|
+
onClick: e => {
|
|
30
|
+
onClick && onClick(e);
|
|
31
|
+
triggerProps.onClick && triggerProps.onClick(e);
|
|
32
|
+
},
|
|
29
33
|
testId: testId,
|
|
30
34
|
triggerRef: triggerProps.triggerRef,
|
|
31
35
|
hasNestedDropdownMenu: true,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useToolbarUI } from '../hooks/ui-context';
|
|
3
|
+
export const ACTION_SUBJECT = {
|
|
4
|
+
TOOLBAR: 'toolbar',
|
|
5
|
+
TOOLBAR_DROPDOWN_MENU: 'toolbarDropdownMenu'
|
|
6
|
+
};
|
|
7
|
+
export const ViewEventEmitter = ({
|
|
8
|
+
actionSubjectId,
|
|
9
|
+
actionSubject
|
|
10
|
+
}) => {
|
|
11
|
+
const isMountedRef = useRef(false);
|
|
12
|
+
const {
|
|
13
|
+
fireAnalyticsEvent
|
|
14
|
+
} = useToolbarUI();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (isMountedRef.current) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
isMountedRef.current = true;
|
|
20
|
+
const payload = {
|
|
21
|
+
action: 'viewed',
|
|
22
|
+
actionSubject,
|
|
23
|
+
actionSubjectId,
|
|
24
|
+
eventType: 'ui'
|
|
25
|
+
};
|
|
26
|
+
fireAnalyticsEvent && fireAnalyticsEvent(payload);
|
|
27
|
+
}, [actionSubjectId, actionSubject, fireAnalyticsEvent]);
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
@@ -3,7 +3,8 @@ var ToolbarUIContext = /*#__PURE__*/createContext({
|
|
|
3
3
|
onDropdownOpenChanged: function onDropdownOpenChanged() {},
|
|
4
4
|
preventDefaultOnMouseDown: false,
|
|
5
5
|
isDisabled: false,
|
|
6
|
-
popupsMountPoint: undefined
|
|
6
|
+
popupsMountPoint: undefined,
|
|
7
|
+
fireAnalyticsEvent: undefined
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -23,7 +24,8 @@ export var ToolbarUIProvider = function ToolbarUIProvider(_ref) {
|
|
|
23
24
|
isDisabled = _ref.isDisabled,
|
|
24
25
|
popupsMountPoint = _ref.popupsMountPoint,
|
|
25
26
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
26
|
-
popupsScrollableElement = _ref.popupsScrollableElement
|
|
27
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
28
|
+
fireAnalyticsEvent = _ref.fireAnalyticsEvent;
|
|
27
29
|
return /*#__PURE__*/React.createElement(ToolbarUIContext.Provider, {
|
|
28
30
|
value: {
|
|
29
31
|
onDropdownOpenChanged: onDropdownOpenChanged,
|
|
@@ -31,7 +33,8 @@ export var ToolbarUIProvider = function ToolbarUIProvider(_ref) {
|
|
|
31
33
|
isDisabled: isDisabled,
|
|
32
34
|
popupsMountPoint: popupsMountPoint,
|
|
33
35
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
34
|
-
popupsScrollableElement: popupsScrollableElement
|
|
36
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
37
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
35
38
|
}
|
|
36
39
|
}, children);
|
|
37
40
|
};
|
package/dist/esm/ui/Toolbar.js
CHANGED
|
@@ -8,6 +8,7 @@ import { cx } from '@atlaskit/css';
|
|
|
8
8
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
9
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
10
|
import { ResponsiveContainer, ResponsiveWrapper } from './ResponsiveContainer';
|
|
11
|
+
import { ACTION_SUBJECT, ViewEventEmitter } from './ViewEventEmitter';
|
|
11
12
|
var styles = {
|
|
12
13
|
toolbarBase: "_2rko1qi0 _zulp1b66 _1e0c1txw _4cvr1h6o",
|
|
13
14
|
toolbar: "_bfhk1bhr _4t3i14no _u5f31b66 _19bv1b66 _16qs1cd0",
|
|
@@ -22,13 +23,17 @@ var styles = {
|
|
|
22
23
|
*/
|
|
23
24
|
export var Toolbar = function Toolbar(_ref) {
|
|
24
25
|
var children = _ref.children,
|
|
25
|
-
label = _ref.label
|
|
26
|
+
label = _ref.label,
|
|
27
|
+
actionSubjectId = _ref.actionSubjectId;
|
|
26
28
|
var isResponsiveEnabled = expValEquals('platform_editor_aifc_selection_toolbar_responsive', 'isEnabled', true);
|
|
27
29
|
var toolbar = /*#__PURE__*/React.createElement(Box, {
|
|
28
30
|
xcss: cx(styles.toolbarBase, styles.toolbar, isResponsiveEnabled && styles.toolbarResponsive, expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) && styles.hiddenSelectors),
|
|
29
31
|
role: "toolbar",
|
|
30
32
|
"aria-label": label
|
|
31
|
-
},
|
|
33
|
+
}, expValEquals('platform_editor_toolbar_aifc_toolbar_analytic', 'isEnabled', true) ? /*#__PURE__*/React.createElement(ViewEventEmitter, {
|
|
34
|
+
actionSubject: ACTION_SUBJECT.TOOLBAR,
|
|
35
|
+
actionSubjectId: actionSubjectId
|
|
36
|
+
}) : null, children);
|
|
32
37
|
if (isResponsiveEnabled) {
|
|
33
38
|
return /*#__PURE__*/React.createElement(ResponsiveWrapper, null, toolbar);
|
|
34
39
|
} else {
|
|
@@ -47,9 +47,9 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
|
47
47
|
"aria-controls": triggerProps['aria-controls'],
|
|
48
48
|
onBlur: triggerProps.onBlur,
|
|
49
49
|
onClick: function onClick(e) {
|
|
50
|
+
_onClick && _onClick(e, !(menuContext !== null && menuContext !== void 0 && menuContext.isOpen));
|
|
50
51
|
handleClick();
|
|
51
52
|
triggerProps.onClick && triggerProps.onClick(e);
|
|
52
|
-
_onClick && _onClick(e);
|
|
53
53
|
},
|
|
54
54
|
onFocus: triggerProps.onFocus,
|
|
55
55
|
testId: testId,
|
|
@@ -18,7 +18,8 @@ export var ToolbarNestedDropdownMenu = function ToolbarNestedDropdownMenu(_ref)
|
|
|
18
18
|
isDisabled = _ref.isDisabled,
|
|
19
19
|
testId = _ref.testId,
|
|
20
20
|
_ref$enableMaxHeight = _ref.enableMaxHeight,
|
|
21
|
-
enableMaxHeight = _ref$enableMaxHeight === void 0 ? false : _ref$enableMaxHeight
|
|
21
|
+
enableMaxHeight = _ref$enableMaxHeight === void 0 ? false : _ref$enableMaxHeight,
|
|
22
|
+
_onClick = _ref.onClick;
|
|
22
23
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
23
24
|
placement: "right-start",
|
|
24
25
|
trigger: function trigger(triggerProps) {
|
|
@@ -26,7 +27,10 @@ export var ToolbarNestedDropdownMenu = function ToolbarNestedDropdownMenu(_ref)
|
|
|
26
27
|
elemBefore: elemBefore,
|
|
27
28
|
elemAfter: elemAfter,
|
|
28
29
|
isSelected: triggerProps.isSelected,
|
|
29
|
-
onClick:
|
|
30
|
+
onClick: function onClick(e) {
|
|
31
|
+
_onClick && _onClick(e);
|
|
32
|
+
triggerProps.onClick && triggerProps.onClick(e);
|
|
33
|
+
},
|
|
30
34
|
testId: testId,
|
|
31
35
|
triggerRef: triggerProps.triggerRef,
|
|
32
36
|
hasNestedDropdownMenu: true,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useToolbarUI } from '../hooks/ui-context';
|
|
3
|
+
export var ACTION_SUBJECT = {
|
|
4
|
+
TOOLBAR: 'toolbar',
|
|
5
|
+
TOOLBAR_DROPDOWN_MENU: 'toolbarDropdownMenu'
|
|
6
|
+
};
|
|
7
|
+
export var ViewEventEmitter = function ViewEventEmitter(_ref) {
|
|
8
|
+
var actionSubjectId = _ref.actionSubjectId,
|
|
9
|
+
actionSubject = _ref.actionSubject;
|
|
10
|
+
var isMountedRef = useRef(false);
|
|
11
|
+
var _useToolbarUI = useToolbarUI(),
|
|
12
|
+
fireAnalyticsEvent = _useToolbarUI.fireAnalyticsEvent;
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
if (isMountedRef.current) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
isMountedRef.current = true;
|
|
18
|
+
var payload = {
|
|
19
|
+
action: 'viewed',
|
|
20
|
+
actionSubject: actionSubject,
|
|
21
|
+
actionSubjectId: actionSubjectId,
|
|
22
|
+
eventType: 'ui'
|
|
23
|
+
};
|
|
24
|
+
fireAnalyticsEvent && fireAnalyticsEvent(payload);
|
|
25
|
+
}, [actionSubjectId, actionSubject, fireAnalyticsEvent]);
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { OnOpenChangeArgs } from '@atlaskit/dropdown-menu';
|
|
3
|
+
type AnalyticsEventPayload = {
|
|
4
|
+
action: string;
|
|
5
|
+
actionSubject?: string;
|
|
6
|
+
actionSubjectId?: string;
|
|
7
|
+
eventType: string;
|
|
8
|
+
};
|
|
9
|
+
type FireAnalyticsEvent = (payload: AnalyticsEventPayload) => void | undefined;
|
|
3
10
|
export type ToolbarUIContextType = {
|
|
11
|
+
fireAnalyticsEvent?: FireAnalyticsEvent;
|
|
4
12
|
/**
|
|
5
13
|
* Indicates whether the toolbar is disabled when the editor is offline.
|
|
6
14
|
*/
|
|
@@ -26,5 +34,5 @@ export declare const useToolbarUI: () => ToolbarUIContextType;
|
|
|
26
34
|
type ToolbarUIProviderProps = {
|
|
27
35
|
children: React.ReactNode;
|
|
28
36
|
} & ToolbarUIContextType;
|
|
29
|
-
export declare const ToolbarUIProvider: ({ children, onDropdownOpenChanged, preventDefaultOnMouseDown, isDisabled, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, }: ToolbarUIProviderProps) => React.JSX.Element;
|
|
37
|
+
export declare const ToolbarUIProvider: ({ children, onDropdownOpenChanged, preventDefaultOnMouseDown, isDisabled, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, fireAnalyticsEvent, }: ToolbarUIProviderProps) => React.JSX.Element;
|
|
30
38
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
import type { ResponsiveContainerProps } from './ResponsiveContainer';
|
|
3
|
+
import { type ViewEventEmitterProps } from './ViewEventEmitter';
|
|
3
4
|
type ToolbarProps = {
|
|
4
5
|
children?: ReactNode;
|
|
5
6
|
/**
|
|
@@ -8,13 +9,13 @@ type ToolbarProps = {
|
|
|
8
9
|
* use case: query select the toolbar to position floating toolbar
|
|
9
10
|
*/
|
|
10
11
|
label: string;
|
|
11
|
-
};
|
|
12
|
+
} & ViewEventEmitterProps;
|
|
12
13
|
/**
|
|
13
14
|
* A simple component representing a toolbar with box shadows - used to represent a secondary/floating toolbar
|
|
14
15
|
*
|
|
15
16
|
* @note: Responsiveness support replies on container query with container editor-area and media query
|
|
16
17
|
*/
|
|
17
|
-
export declare const Toolbar: ({ children, label }: ToolbarProps) => React.JSX.Element;
|
|
18
|
+
export declare const Toolbar: ({ children, label, actionSubjectId }: ToolbarProps) => React.JSX.Element;
|
|
18
19
|
type PrimaryToolbarProps = ToolbarProps & ResponsiveContainerProps;
|
|
19
20
|
/**
|
|
20
21
|
* A simple component representing a toolbar without box shadows - used to represent a primary toolbar
|
|
@@ -16,7 +16,7 @@ type ToolbarDropdownMenuProps = {
|
|
|
16
16
|
iconBefore: React.ReactNode;
|
|
17
17
|
isDisabled?: boolean;
|
|
18
18
|
label?: string;
|
|
19
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement
|
|
19
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>, isOpen: boolean) => void;
|
|
20
20
|
testId?: string;
|
|
21
21
|
};
|
|
22
22
|
export declare const ToolbarDropdownMenu: ({ iconBefore, children, isDisabled, testId, label, hasSectionMargin, enableMaxHeight, onClick, }: ToolbarDropdownMenuProps) => JSX.Element;
|
|
@@ -12,8 +12,9 @@ type ToolbarNestedDropdownMenuProps = {
|
|
|
12
12
|
*/
|
|
13
13
|
enableMaxHeight?: boolean;
|
|
14
14
|
isDisabled?: boolean;
|
|
15
|
+
onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;
|
|
15
16
|
testId?: string;
|
|
16
17
|
text?: string;
|
|
17
18
|
};
|
|
18
|
-
export declare const ToolbarNestedDropdownMenu: ({ elemBefore, text, elemAfter, children, isDisabled, testId, enableMaxHeight, }: ToolbarNestedDropdownMenuProps) => JSX.Element;
|
|
19
|
+
export declare const ToolbarNestedDropdownMenu: ({ elemBefore, text, elemAfter, children, isDisabled, testId, enableMaxHeight, onClick, }: ToolbarNestedDropdownMenuProps) => JSX.Element;
|
|
19
20
|
export {};
|
|
@@ -6,5 +6,5 @@ type ToolbarTooltipProps = {
|
|
|
6
6
|
delay?: number;
|
|
7
7
|
position?: PositionType;
|
|
8
8
|
};
|
|
9
|
-
export declare const ToolbarTooltip: ({ content, children, position, delay }: ToolbarTooltipProps) => React.JSX.Element;
|
|
9
|
+
export declare const ToolbarTooltip: ({ content, children, position, delay, }: ToolbarTooltipProps) => React.JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const ACTION_SUBJECT: {
|
|
2
|
+
TOOLBAR: string;
|
|
3
|
+
TOOLBAR_DROPDOWN_MENU: string;
|
|
4
|
+
};
|
|
5
|
+
export type ViewEventEmitterProps = {
|
|
6
|
+
actionSubject?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Name of dropdown to identify in analytic events
|
|
9
|
+
*/
|
|
10
|
+
actionSubjectId?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const ViewEventEmitter: ({ actionSubjectId, actionSubject }: ViewEventEmitterProps) => null;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { OnOpenChangeArgs } from '@atlaskit/dropdown-menu';
|
|
3
|
+
type AnalyticsEventPayload = {
|
|
4
|
+
action: string;
|
|
5
|
+
actionSubject?: string;
|
|
6
|
+
actionSubjectId?: string;
|
|
7
|
+
eventType: string;
|
|
8
|
+
};
|
|
9
|
+
type FireAnalyticsEvent = (payload: AnalyticsEventPayload) => void | undefined;
|
|
3
10
|
export type ToolbarUIContextType = {
|
|
11
|
+
fireAnalyticsEvent?: FireAnalyticsEvent;
|
|
4
12
|
/**
|
|
5
13
|
* Indicates whether the toolbar is disabled when the editor is offline.
|
|
6
14
|
*/
|
|
@@ -26,5 +34,5 @@ export declare const useToolbarUI: () => ToolbarUIContextType;
|
|
|
26
34
|
type ToolbarUIProviderProps = {
|
|
27
35
|
children: React.ReactNode;
|
|
28
36
|
} & ToolbarUIContextType;
|
|
29
|
-
export declare const ToolbarUIProvider: ({ children, onDropdownOpenChanged, preventDefaultOnMouseDown, isDisabled, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, }: ToolbarUIProviderProps) => React.JSX.Element;
|
|
37
|
+
export declare const ToolbarUIProvider: ({ children, onDropdownOpenChanged, preventDefaultOnMouseDown, isDisabled, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, fireAnalyticsEvent, }: ToolbarUIProviderProps) => React.JSX.Element;
|
|
30
38
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
import type { ResponsiveContainerProps } from './ResponsiveContainer';
|
|
3
|
+
import { type ViewEventEmitterProps } from './ViewEventEmitter';
|
|
3
4
|
type ToolbarProps = {
|
|
4
5
|
children?: ReactNode;
|
|
5
6
|
/**
|
|
@@ -8,13 +9,13 @@ type ToolbarProps = {
|
|
|
8
9
|
* use case: query select the toolbar to position floating toolbar
|
|
9
10
|
*/
|
|
10
11
|
label: string;
|
|
11
|
-
};
|
|
12
|
+
} & ViewEventEmitterProps;
|
|
12
13
|
/**
|
|
13
14
|
* A simple component representing a toolbar with box shadows - used to represent a secondary/floating toolbar
|
|
14
15
|
*
|
|
15
16
|
* @note: Responsiveness support replies on container query with container editor-area and media query
|
|
16
17
|
*/
|
|
17
|
-
export declare const Toolbar: ({ children, label }: ToolbarProps) => React.JSX.Element;
|
|
18
|
+
export declare const Toolbar: ({ children, label, actionSubjectId }: ToolbarProps) => React.JSX.Element;
|
|
18
19
|
type PrimaryToolbarProps = ToolbarProps & ResponsiveContainerProps;
|
|
19
20
|
/**
|
|
20
21
|
* A simple component representing a toolbar without box shadows - used to represent a primary toolbar
|
|
@@ -16,7 +16,7 @@ type ToolbarDropdownMenuProps = {
|
|
|
16
16
|
iconBefore: React.ReactNode;
|
|
17
17
|
isDisabled?: boolean;
|
|
18
18
|
label?: string;
|
|
19
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement
|
|
19
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>, isOpen: boolean) => void;
|
|
20
20
|
testId?: string;
|
|
21
21
|
};
|
|
22
22
|
export declare const ToolbarDropdownMenu: ({ iconBefore, children, isDisabled, testId, label, hasSectionMargin, enableMaxHeight, onClick, }: ToolbarDropdownMenuProps) => JSX.Element;
|
|
@@ -12,8 +12,9 @@ type ToolbarNestedDropdownMenuProps = {
|
|
|
12
12
|
*/
|
|
13
13
|
enableMaxHeight?: boolean;
|
|
14
14
|
isDisabled?: boolean;
|
|
15
|
+
onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;
|
|
15
16
|
testId?: string;
|
|
16
17
|
text?: string;
|
|
17
18
|
};
|
|
18
|
-
export declare const ToolbarNestedDropdownMenu: ({ elemBefore, text, elemAfter, children, isDisabled, testId, enableMaxHeight, }: ToolbarNestedDropdownMenuProps) => JSX.Element;
|
|
19
|
+
export declare const ToolbarNestedDropdownMenu: ({ elemBefore, text, elemAfter, children, isDisabled, testId, enableMaxHeight, onClick, }: ToolbarNestedDropdownMenuProps) => JSX.Element;
|
|
19
20
|
export {};
|
|
@@ -6,5 +6,5 @@ type ToolbarTooltipProps = {
|
|
|
6
6
|
delay?: number;
|
|
7
7
|
position?: PositionType;
|
|
8
8
|
};
|
|
9
|
-
export declare const ToolbarTooltip: ({ content, children, position, delay }: ToolbarTooltipProps) => React.JSX.Element;
|
|
9
|
+
export declare const ToolbarTooltip: ({ content, children, position, delay, }: ToolbarTooltipProps) => React.JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const ACTION_SUBJECT: {
|
|
2
|
+
TOOLBAR: string;
|
|
3
|
+
TOOLBAR_DROPDOWN_MENU: string;
|
|
4
|
+
};
|
|
5
|
+
export type ViewEventEmitterProps = {
|
|
6
|
+
actionSubject?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Name of dropdown to identify in analytic events
|
|
9
|
+
*/
|
|
10
|
+
actionSubjectId?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const ViewEventEmitter: ({ actionSubjectId, actionSubject }: ViewEventEmitterProps) => null;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"registry": "https://registry.npmjs.org/"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.9.0",
|
|
7
7
|
"description": "Common UI for Toolbars across the platform",
|
|
8
8
|
"atlassian": {
|
|
9
9
|
"team": "Editor: Jenga",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@atlaskit/platform-feature-flags-react": "^0.3.0",
|
|
32
32
|
"@atlaskit/popup": "^4.3.0",
|
|
33
33
|
"@atlaskit/primitives": "^14.14.0",
|
|
34
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
34
|
+
"@atlaskit/tmp-editor-statsig": "^12.21.0",
|
|
35
35
|
"@atlaskit/tokens": "^6.3.0",
|
|
36
36
|
"@atlaskit/tooltip": "^20.4.0",
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|