@atlaskit/editor-common 111.13.1 → 111.14.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 +7 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/vanilla-tooltip/index.js +180 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/vanilla-tooltip/index.js +148 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/vanilla-tooltip/index.js +173 -0
- package/dist/types/vanilla-tooltip/index.d.ts +29 -0
- package/dist/types-ts4.5/vanilla-tooltip/index.d.ts +29 -0
- package/package.json +2 -1
- package/vanilla-tooltip/package.json +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 111.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a287a6035ed71`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a287a6035ed71) -
|
|
8
|
+
[EDITOR-5005] export VanillaTooltip from the editor-common package and update references
|
|
9
|
+
|
|
3
10
|
## 111.13.1
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -19,7 +19,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
19
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
20
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
21
21
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
22
|
-
var packageVersion = "111.13.
|
|
22
|
+
var packageVersion = "111.13.1";
|
|
23
23
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
24
24
|
// Remove URL as it has UGC
|
|
25
25
|
// Ignored via go/ees007
|
|
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
24
24
|
* @jsx jsx
|
|
25
25
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
26
26
|
var packageName = "@atlaskit/editor-common";
|
|
27
|
-
var packageVersion = "111.13.
|
|
27
|
+
var packageVersion = "111.13.1";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var fadeIn = (0, _react2.keyframes)({
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.VanillaTooltip = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _core = require("@popperjs/core");
|
|
12
|
+
var _bindEventListener = require("bind-event-listener");
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
var startingOffset = {
|
|
16
|
+
name: 'offset',
|
|
17
|
+
options: {
|
|
18
|
+
offset: [0, 4]
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var endingOffset = {
|
|
22
|
+
name: 'offset',
|
|
23
|
+
options: {
|
|
24
|
+
offset: [0, 8]
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A tooltip component similar to "@atlaskit/tooltip" but built for vanilla scenarios
|
|
30
|
+
*
|
|
31
|
+
* Uses Popover API for accessibility + stacking context: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
|
|
32
|
+
* Uses popperJS for positioning
|
|
33
|
+
*/
|
|
34
|
+
var VanillaTooltip = exports.VanillaTooltip = /*#__PURE__*/function () {
|
|
35
|
+
function VanillaTooltip(button, content,
|
|
36
|
+
/**
|
|
37
|
+
* Id associated to the tooltip - must be unique.
|
|
38
|
+
*/
|
|
39
|
+
id,
|
|
40
|
+
/**
|
|
41
|
+
* Class Name – used for styling.
|
|
42
|
+
*/
|
|
43
|
+
className) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
var timeout = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 300;
|
|
46
|
+
(0, _classCallCheck2.default)(this, VanillaTooltip);
|
|
47
|
+
(0, _defineProperty2.default)(this, "listeners", []);
|
|
48
|
+
(0, _defineProperty2.default)(this, "shouldHidePopover", false);
|
|
49
|
+
(0, _defineProperty2.default)(this, "isDisplayed", false);
|
|
50
|
+
this.button = button;
|
|
51
|
+
this.timeout = timeout;
|
|
52
|
+
var tooltip = document.createElement('span');
|
|
53
|
+
tooltip.role = 'tooltip';
|
|
54
|
+
tooltip.popover = 'hint';
|
|
55
|
+
tooltip.className = className;
|
|
56
|
+
tooltip.id = id;
|
|
57
|
+
tooltip.textContent = content;
|
|
58
|
+
this.tooltip = tooltip;
|
|
59
|
+
|
|
60
|
+
// Button preparation
|
|
61
|
+
button.appendChild(tooltip);
|
|
62
|
+
// Prepare the button to have the popover target and accessibility properties
|
|
63
|
+
button.setAttribute('popovertarget', tooltip.id);
|
|
64
|
+
button.setAttribute('aria-describedby', tooltip.id);
|
|
65
|
+
var showEvents = ['mouseenter', 'focus'];
|
|
66
|
+
var hideEvents = ['mouseleave', 'blur'];
|
|
67
|
+
showEvents.forEach(function (event) {
|
|
68
|
+
_this.listeners.push((0, _bindEventListener.bind)(button, {
|
|
69
|
+
type: event,
|
|
70
|
+
listener: function listener() {
|
|
71
|
+
return _this.show();
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
});
|
|
75
|
+
hideEvents.forEach(function (event) {
|
|
76
|
+
_this.listeners.push((0, _bindEventListener.bind)(button, {
|
|
77
|
+
type: event,
|
|
78
|
+
listener: function listener() {
|
|
79
|
+
return _this.hide();
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
82
|
+
});
|
|
83
|
+
this.listeners.push((0, _bindEventListener.bind)(window, {
|
|
84
|
+
type: 'keydown',
|
|
85
|
+
listener: function listener(e) {
|
|
86
|
+
if (e.key === 'Escape') {
|
|
87
|
+
_this.hide(true);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
// Hide the tooltip if the hide transition has completed
|
|
93
|
+
this.tooltip.ontransitionend = function () {
|
|
94
|
+
if (_this.shouldHidePopover) {
|
|
95
|
+
_this.tooltip.hidePopover();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return (0, _createClass2.default)(VanillaTooltip, [{
|
|
100
|
+
key: "createPopperInstance",
|
|
101
|
+
value: function createPopperInstance() {
|
|
102
|
+
this.popperInstance = (0, _core.createPopper)(this.button, this.tooltip, {
|
|
103
|
+
placement: 'top',
|
|
104
|
+
modifiers: [startingOffset]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "destroy",
|
|
109
|
+
value: function destroy() {
|
|
110
|
+
var _this$popperInstance;
|
|
111
|
+
(_this$popperInstance = this.popperInstance) === null || _this$popperInstance === void 0 || _this$popperInstance.destroy();
|
|
112
|
+
this.listeners.forEach(function (listener) {
|
|
113
|
+
listener();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
key: "hide",
|
|
118
|
+
value: function hide() {
|
|
119
|
+
var _this2 = this;
|
|
120
|
+
var immediate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
121
|
+
clearTimeout(this.currentTimeoutId);
|
|
122
|
+
this.shouldHidePopover = true;
|
|
123
|
+
// Disable the event listeners
|
|
124
|
+
this.currentTimeoutId = setTimeout(function () {
|
|
125
|
+
var _this2$popperInstance;
|
|
126
|
+
(_this2$popperInstance = _this2.popperInstance) === null || _this2$popperInstance === void 0 || _this2$popperInstance.setOptions(function (options) {
|
|
127
|
+
return _objectSpread(_objectSpread({}, options), {}, {
|
|
128
|
+
modifiers: [startingOffset, {
|
|
129
|
+
name: 'eventListeners',
|
|
130
|
+
enabled: false
|
|
131
|
+
}]
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
_this2.tooltip.style.opacity = '0';
|
|
135
|
+
_this2.isDisplayed = false;
|
|
136
|
+
// If transition animations are disabled immediately hide the popover
|
|
137
|
+
if (_this2.tooltip.style.transition === 'none') {
|
|
138
|
+
_this2.tooltip.hidePopover();
|
|
139
|
+
}
|
|
140
|
+
}, immediate ? 0 : this.timeout);
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "show",
|
|
144
|
+
value: function show() {
|
|
145
|
+
var _this3 = this;
|
|
146
|
+
if (this.isDisplayed) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
clearTimeout(this.currentTimeoutId);
|
|
150
|
+
this.shouldHidePopover = false;
|
|
151
|
+
|
|
152
|
+
// Make the tooltip visible - but hide until
|
|
153
|
+
this.tooltip.style.visibility = 'hidden';
|
|
154
|
+
this.tooltip.showPopover();
|
|
155
|
+
|
|
156
|
+
// Update its position
|
|
157
|
+
if (!this.popperInstance) {
|
|
158
|
+
this.createPopperInstance();
|
|
159
|
+
} else {
|
|
160
|
+
this.popperInstance.update();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Enable the event listeners
|
|
164
|
+
this.currentTimeoutId = setTimeout(function () {
|
|
165
|
+
var _this3$popperInstance;
|
|
166
|
+
_this3.tooltip.style.opacity = '1';
|
|
167
|
+
_this3.tooltip.style.visibility = 'visible';
|
|
168
|
+
(_this3$popperInstance = _this3.popperInstance) === null || _this3$popperInstance === void 0 || _this3$popperInstance.setOptions(function (options) {
|
|
169
|
+
return _objectSpread(_objectSpread({}, options), {}, {
|
|
170
|
+
modifiers: [endingOffset, {
|
|
171
|
+
name: 'eventListeners',
|
|
172
|
+
enabled: true
|
|
173
|
+
}]
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
_this3.isDisplayed = true;
|
|
177
|
+
}, this.timeout);
|
|
178
|
+
}
|
|
179
|
+
}]);
|
|
180
|
+
}();
|
|
@@ -4,7 +4,7 @@ import { isFedRamp } from './environment';
|
|
|
4
4
|
import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
|
|
5
5
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
6
6
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
7
|
-
const packageVersion = "111.13.
|
|
7
|
+
const packageVersion = "111.13.1";
|
|
8
8
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
9
9
|
// Remove URL as it has UGC
|
|
10
10
|
// Ignored via go/ees007
|
|
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
import Layer from '../Layer';
|
|
16
16
|
const packageName = "@atlaskit/editor-common";
|
|
17
|
-
const packageVersion = "111.13.
|
|
17
|
+
const packageVersion = "111.13.1";
|
|
18
18
|
const halfFocusRing = 1;
|
|
19
19
|
const dropOffset = '0, 8';
|
|
20
20
|
const fadeIn = keyframes({
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { createPopper } from '@popperjs/core';
|
|
3
|
+
import { bind } from 'bind-event-listener';
|
|
4
|
+
const startingOffset = {
|
|
5
|
+
name: 'offset',
|
|
6
|
+
options: {
|
|
7
|
+
offset: [0, 4]
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const endingOffset = {
|
|
11
|
+
name: 'offset',
|
|
12
|
+
options: {
|
|
13
|
+
offset: [0, 8]
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A tooltip component similar to "@atlaskit/tooltip" but built for vanilla scenarios
|
|
19
|
+
*
|
|
20
|
+
* Uses Popover API for accessibility + stacking context: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
|
|
21
|
+
* Uses popperJS for positioning
|
|
22
|
+
*/
|
|
23
|
+
export class VanillaTooltip {
|
|
24
|
+
constructor(button, content,
|
|
25
|
+
/**
|
|
26
|
+
* Id associated to the tooltip - must be unique.
|
|
27
|
+
*/
|
|
28
|
+
id,
|
|
29
|
+
/**
|
|
30
|
+
* Class Name – used for styling.
|
|
31
|
+
*/
|
|
32
|
+
className, timeout = 300) {
|
|
33
|
+
_defineProperty(this, "listeners", []);
|
|
34
|
+
_defineProperty(this, "shouldHidePopover", false);
|
|
35
|
+
_defineProperty(this, "isDisplayed", false);
|
|
36
|
+
this.button = button;
|
|
37
|
+
this.timeout = timeout;
|
|
38
|
+
const tooltip = document.createElement('span');
|
|
39
|
+
tooltip.role = 'tooltip';
|
|
40
|
+
tooltip.popover = 'hint';
|
|
41
|
+
tooltip.className = className;
|
|
42
|
+
tooltip.id = id;
|
|
43
|
+
tooltip.textContent = content;
|
|
44
|
+
this.tooltip = tooltip;
|
|
45
|
+
|
|
46
|
+
// Button preparation
|
|
47
|
+
button.appendChild(tooltip);
|
|
48
|
+
// Prepare the button to have the popover target and accessibility properties
|
|
49
|
+
button.setAttribute('popovertarget', tooltip.id);
|
|
50
|
+
button.setAttribute('aria-describedby', tooltip.id);
|
|
51
|
+
const showEvents = ['mouseenter', 'focus'];
|
|
52
|
+
const hideEvents = ['mouseleave', 'blur'];
|
|
53
|
+
showEvents.forEach(event => {
|
|
54
|
+
this.listeners.push(bind(button, {
|
|
55
|
+
type: event,
|
|
56
|
+
listener: () => this.show()
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
hideEvents.forEach(event => {
|
|
60
|
+
this.listeners.push(bind(button, {
|
|
61
|
+
type: event,
|
|
62
|
+
listener: () => this.hide()
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
this.listeners.push(bind(window, {
|
|
66
|
+
type: 'keydown',
|
|
67
|
+
listener: e => {
|
|
68
|
+
if (e.key === 'Escape') {
|
|
69
|
+
this.hide(true);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
// Hide the tooltip if the hide transition has completed
|
|
75
|
+
this.tooltip.ontransitionend = () => {
|
|
76
|
+
if (this.shouldHidePopover) {
|
|
77
|
+
this.tooltip.hidePopover();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
createPopperInstance() {
|
|
82
|
+
this.popperInstance = createPopper(this.button, this.tooltip, {
|
|
83
|
+
placement: 'top',
|
|
84
|
+
modifiers: [startingOffset]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
destroy() {
|
|
88
|
+
var _this$popperInstance;
|
|
89
|
+
(_this$popperInstance = this.popperInstance) === null || _this$popperInstance === void 0 ? void 0 : _this$popperInstance.destroy();
|
|
90
|
+
this.listeners.forEach(listener => {
|
|
91
|
+
listener();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
hide(immediate = false) {
|
|
95
|
+
clearTimeout(this.currentTimeoutId);
|
|
96
|
+
this.shouldHidePopover = true;
|
|
97
|
+
// Disable the event listeners
|
|
98
|
+
this.currentTimeoutId = setTimeout(() => {
|
|
99
|
+
var _this$popperInstance2;
|
|
100
|
+
(_this$popperInstance2 = this.popperInstance) === null || _this$popperInstance2 === void 0 ? void 0 : _this$popperInstance2.setOptions(options => ({
|
|
101
|
+
...options,
|
|
102
|
+
modifiers: [startingOffset, {
|
|
103
|
+
name: 'eventListeners',
|
|
104
|
+
enabled: false
|
|
105
|
+
}]
|
|
106
|
+
}));
|
|
107
|
+
this.tooltip.style.opacity = '0';
|
|
108
|
+
this.isDisplayed = false;
|
|
109
|
+
// If transition animations are disabled immediately hide the popover
|
|
110
|
+
if (this.tooltip.style.transition === 'none') {
|
|
111
|
+
this.tooltip.hidePopover();
|
|
112
|
+
}
|
|
113
|
+
}, immediate ? 0 : this.timeout);
|
|
114
|
+
}
|
|
115
|
+
show() {
|
|
116
|
+
if (this.isDisplayed) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
clearTimeout(this.currentTimeoutId);
|
|
120
|
+
this.shouldHidePopover = false;
|
|
121
|
+
|
|
122
|
+
// Make the tooltip visible - but hide until
|
|
123
|
+
this.tooltip.style.visibility = 'hidden';
|
|
124
|
+
this.tooltip.showPopover();
|
|
125
|
+
|
|
126
|
+
// Update its position
|
|
127
|
+
if (!this.popperInstance) {
|
|
128
|
+
this.createPopperInstance();
|
|
129
|
+
} else {
|
|
130
|
+
this.popperInstance.update();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Enable the event listeners
|
|
134
|
+
this.currentTimeoutId = setTimeout(() => {
|
|
135
|
+
var _this$popperInstance3;
|
|
136
|
+
this.tooltip.style.opacity = '1';
|
|
137
|
+
this.tooltip.style.visibility = 'visible';
|
|
138
|
+
(_this$popperInstance3 = this.popperInstance) === null || _this$popperInstance3 === void 0 ? void 0 : _this$popperInstance3.setOptions(options => ({
|
|
139
|
+
...options,
|
|
140
|
+
modifiers: [endingOffset, {
|
|
141
|
+
name: 'eventListeners',
|
|
142
|
+
enabled: true
|
|
143
|
+
}]
|
|
144
|
+
}));
|
|
145
|
+
this.isDisplayed = true;
|
|
146
|
+
}, this.timeout);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -10,7 +10,7 @@ import { isFedRamp } from './environment';
|
|
|
10
10
|
import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
|
|
11
11
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
12
12
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
13
|
-
var packageVersion = "111.13.
|
|
13
|
+
var packageVersion = "111.13.1";
|
|
14
14
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
15
15
|
// Remove URL as it has UGC
|
|
16
16
|
// Ignored via go/ees007
|
|
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
21
21
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
22
22
|
import Layer from '../Layer';
|
|
23
23
|
var packageName = "@atlaskit/editor-common";
|
|
24
|
-
var packageVersion = "111.13.
|
|
24
|
+
var packageVersion = "111.13.1";
|
|
25
25
|
var halfFocusRing = 1;
|
|
26
26
|
var dropOffset = '0, 8';
|
|
27
27
|
var fadeIn = keyframes({
|
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { createPopper } from '@popperjs/core';
|
|
7
|
+
import { bind } from 'bind-event-listener';
|
|
8
|
+
var startingOffset = {
|
|
9
|
+
name: 'offset',
|
|
10
|
+
options: {
|
|
11
|
+
offset: [0, 4]
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var endingOffset = {
|
|
15
|
+
name: 'offset',
|
|
16
|
+
options: {
|
|
17
|
+
offset: [0, 8]
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A tooltip component similar to "@atlaskit/tooltip" but built for vanilla scenarios
|
|
23
|
+
*
|
|
24
|
+
* Uses Popover API for accessibility + stacking context: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
|
|
25
|
+
* Uses popperJS for positioning
|
|
26
|
+
*/
|
|
27
|
+
export var VanillaTooltip = /*#__PURE__*/function () {
|
|
28
|
+
function VanillaTooltip(button, content,
|
|
29
|
+
/**
|
|
30
|
+
* Id associated to the tooltip - must be unique.
|
|
31
|
+
*/
|
|
32
|
+
id,
|
|
33
|
+
/**
|
|
34
|
+
* Class Name – used for styling.
|
|
35
|
+
*/
|
|
36
|
+
className) {
|
|
37
|
+
var _this = this;
|
|
38
|
+
var timeout = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 300;
|
|
39
|
+
_classCallCheck(this, VanillaTooltip);
|
|
40
|
+
_defineProperty(this, "listeners", []);
|
|
41
|
+
_defineProperty(this, "shouldHidePopover", false);
|
|
42
|
+
_defineProperty(this, "isDisplayed", false);
|
|
43
|
+
this.button = button;
|
|
44
|
+
this.timeout = timeout;
|
|
45
|
+
var tooltip = document.createElement('span');
|
|
46
|
+
tooltip.role = 'tooltip';
|
|
47
|
+
tooltip.popover = 'hint';
|
|
48
|
+
tooltip.className = className;
|
|
49
|
+
tooltip.id = id;
|
|
50
|
+
tooltip.textContent = content;
|
|
51
|
+
this.tooltip = tooltip;
|
|
52
|
+
|
|
53
|
+
// Button preparation
|
|
54
|
+
button.appendChild(tooltip);
|
|
55
|
+
// Prepare the button to have the popover target and accessibility properties
|
|
56
|
+
button.setAttribute('popovertarget', tooltip.id);
|
|
57
|
+
button.setAttribute('aria-describedby', tooltip.id);
|
|
58
|
+
var showEvents = ['mouseenter', 'focus'];
|
|
59
|
+
var hideEvents = ['mouseleave', 'blur'];
|
|
60
|
+
showEvents.forEach(function (event) {
|
|
61
|
+
_this.listeners.push(bind(button, {
|
|
62
|
+
type: event,
|
|
63
|
+
listener: function listener() {
|
|
64
|
+
return _this.show();
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
});
|
|
68
|
+
hideEvents.forEach(function (event) {
|
|
69
|
+
_this.listeners.push(bind(button, {
|
|
70
|
+
type: event,
|
|
71
|
+
listener: function listener() {
|
|
72
|
+
return _this.hide();
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
this.listeners.push(bind(window, {
|
|
77
|
+
type: 'keydown',
|
|
78
|
+
listener: function listener(e) {
|
|
79
|
+
if (e.key === 'Escape') {
|
|
80
|
+
_this.hide(true);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
// Hide the tooltip if the hide transition has completed
|
|
86
|
+
this.tooltip.ontransitionend = function () {
|
|
87
|
+
if (_this.shouldHidePopover) {
|
|
88
|
+
_this.tooltip.hidePopover();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return _createClass(VanillaTooltip, [{
|
|
93
|
+
key: "createPopperInstance",
|
|
94
|
+
value: function createPopperInstance() {
|
|
95
|
+
this.popperInstance = createPopper(this.button, this.tooltip, {
|
|
96
|
+
placement: 'top',
|
|
97
|
+
modifiers: [startingOffset]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "destroy",
|
|
102
|
+
value: function destroy() {
|
|
103
|
+
var _this$popperInstance;
|
|
104
|
+
(_this$popperInstance = this.popperInstance) === null || _this$popperInstance === void 0 || _this$popperInstance.destroy();
|
|
105
|
+
this.listeners.forEach(function (listener) {
|
|
106
|
+
listener();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "hide",
|
|
111
|
+
value: function hide() {
|
|
112
|
+
var _this2 = this;
|
|
113
|
+
var immediate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
114
|
+
clearTimeout(this.currentTimeoutId);
|
|
115
|
+
this.shouldHidePopover = true;
|
|
116
|
+
// Disable the event listeners
|
|
117
|
+
this.currentTimeoutId = setTimeout(function () {
|
|
118
|
+
var _this2$popperInstance;
|
|
119
|
+
(_this2$popperInstance = _this2.popperInstance) === null || _this2$popperInstance === void 0 || _this2$popperInstance.setOptions(function (options) {
|
|
120
|
+
return _objectSpread(_objectSpread({}, options), {}, {
|
|
121
|
+
modifiers: [startingOffset, {
|
|
122
|
+
name: 'eventListeners',
|
|
123
|
+
enabled: false
|
|
124
|
+
}]
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
_this2.tooltip.style.opacity = '0';
|
|
128
|
+
_this2.isDisplayed = false;
|
|
129
|
+
// If transition animations are disabled immediately hide the popover
|
|
130
|
+
if (_this2.tooltip.style.transition === 'none') {
|
|
131
|
+
_this2.tooltip.hidePopover();
|
|
132
|
+
}
|
|
133
|
+
}, immediate ? 0 : this.timeout);
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "show",
|
|
137
|
+
value: function show() {
|
|
138
|
+
var _this3 = this;
|
|
139
|
+
if (this.isDisplayed) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
clearTimeout(this.currentTimeoutId);
|
|
143
|
+
this.shouldHidePopover = false;
|
|
144
|
+
|
|
145
|
+
// Make the tooltip visible - but hide until
|
|
146
|
+
this.tooltip.style.visibility = 'hidden';
|
|
147
|
+
this.tooltip.showPopover();
|
|
148
|
+
|
|
149
|
+
// Update its position
|
|
150
|
+
if (!this.popperInstance) {
|
|
151
|
+
this.createPopperInstance();
|
|
152
|
+
} else {
|
|
153
|
+
this.popperInstance.update();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Enable the event listeners
|
|
157
|
+
this.currentTimeoutId = setTimeout(function () {
|
|
158
|
+
var _this3$popperInstance;
|
|
159
|
+
_this3.tooltip.style.opacity = '1';
|
|
160
|
+
_this3.tooltip.style.visibility = 'visible';
|
|
161
|
+
(_this3$popperInstance = _this3.popperInstance) === null || _this3$popperInstance === void 0 || _this3$popperInstance.setOptions(function (options) {
|
|
162
|
+
return _objectSpread(_objectSpread({}, options), {}, {
|
|
163
|
+
modifiers: [endingOffset, {
|
|
164
|
+
name: 'eventListeners',
|
|
165
|
+
enabled: true
|
|
166
|
+
}]
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
_this3.isDisplayed = true;
|
|
170
|
+
}, this.timeout);
|
|
171
|
+
}
|
|
172
|
+
}]);
|
|
173
|
+
}();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tooltip component similar to "@atlaskit/tooltip" but built for vanilla scenarios
|
|
3
|
+
*
|
|
4
|
+
* Uses Popover API for accessibility + stacking context: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
|
|
5
|
+
* Uses popperJS for positioning
|
|
6
|
+
*/
|
|
7
|
+
export declare class VanillaTooltip {
|
|
8
|
+
private button;
|
|
9
|
+
private timeout;
|
|
10
|
+
private popperInstance;
|
|
11
|
+
private listeners;
|
|
12
|
+
private currentTimeoutId;
|
|
13
|
+
private shouldHidePopover;
|
|
14
|
+
private tooltip;
|
|
15
|
+
private isDisplayed;
|
|
16
|
+
constructor(button: HTMLButtonElement, content: string,
|
|
17
|
+
/**
|
|
18
|
+
* Id associated to the tooltip - must be unique.
|
|
19
|
+
*/
|
|
20
|
+
id: string,
|
|
21
|
+
/**
|
|
22
|
+
* Class Name – used for styling.
|
|
23
|
+
*/
|
|
24
|
+
className: string, timeout?: number);
|
|
25
|
+
private createPopperInstance;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
private hide;
|
|
28
|
+
private show;
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tooltip component similar to "@atlaskit/tooltip" but built for vanilla scenarios
|
|
3
|
+
*
|
|
4
|
+
* Uses Popover API for accessibility + stacking context: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
|
|
5
|
+
* Uses popperJS for positioning
|
|
6
|
+
*/
|
|
7
|
+
export declare class VanillaTooltip {
|
|
8
|
+
private button;
|
|
9
|
+
private timeout;
|
|
10
|
+
private popperInstance;
|
|
11
|
+
private listeners;
|
|
12
|
+
private currentTimeoutId;
|
|
13
|
+
private shouldHidePopover;
|
|
14
|
+
private tooltip;
|
|
15
|
+
private isDisplayed;
|
|
16
|
+
constructor(button: HTMLButtonElement, content: string,
|
|
17
|
+
/**
|
|
18
|
+
* Id associated to the tooltip - must be unique.
|
|
19
|
+
*/
|
|
20
|
+
id: string,
|
|
21
|
+
/**
|
|
22
|
+
* Class Name – used for styling.
|
|
23
|
+
*/
|
|
24
|
+
className: string, timeout?: number);
|
|
25
|
+
private createPopperInstance;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
private hide;
|
|
28
|
+
private show;
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "111.
|
|
3
|
+
"version": "111.14.0",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"@babel/runtime": "^7.0.0",
|
|
89
89
|
"@compiled/react": "^0.18.6",
|
|
90
90
|
"@emotion/react": "^11.7.1",
|
|
91
|
+
"@popperjs/core": "^2.11.8",
|
|
91
92
|
"@sentry/browser": "^6.18.2",
|
|
92
93
|
"@sentry/integrations": "^6.18.2",
|
|
93
94
|
"@sentry/types": "^6.18.2",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-common/vanilla-tooltip",
|
|
3
|
+
"main": "../dist/cjs/vanilla-tooltip/index.js",
|
|
4
|
+
"module": "../dist/esm/vanilla-tooltip/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/vanilla-tooltip/index.js",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.compiled.css"
|
|
8
|
+
],
|
|
9
|
+
"types": "../dist/types/vanilla-tooltip/index.d.ts",
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
">=4.5 <5.9": {
|
|
12
|
+
"*": [
|
|
13
|
+
"../dist/types-ts4.5/vanilla-tooltip/index.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|