@atlaskit/profilecard 19.17.2 → 19.17.4
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 +12 -0
- package/dist/cjs/client/RovoAgentCardClient.js +82 -0
- package/dist/cjs/client/getAgentInfo.js +80 -0
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/Agent/AgentProfileCard.js +13 -0
- package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +25 -0
- package/dist/cjs/components/Agent/lazyAgentProfileCard.js +17 -0
- package/dist/cjs/components/common/PopupTrigger.js +54 -0
- package/dist/cjs/components/common/ProfileCardTrigger.js +94 -0
- package/dist/cjs/components/common/types.js +5 -0
- package/dist/cjs/util/analytics.js +6 -2
- package/dist/es2019/client/RovoAgentCardClient.js +53 -0
- package/dist/es2019/client/getAgentInfo.js +29 -0
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/Agent/AgentProfileCard.js +7 -0
- package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +16 -0
- package/dist/es2019/components/Agent/lazyAgentProfileCard.js +3 -0
- package/dist/es2019/components/common/PopupTrigger.js +41 -0
- package/dist/es2019/components/common/ProfileCardTrigger.js +78 -0
- package/dist/es2019/components/common/types.js +1 -0
- package/dist/es2019/util/analytics.js +4 -2
- package/dist/esm/client/RovoAgentCardClient.js +76 -0
- package/dist/esm/client/getAgentInfo.js +72 -0
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/Agent/AgentProfileCard.js +6 -0
- package/dist/esm/components/Agent/AgentProfileCardTrigger.js +18 -0
- package/dist/esm/components/Agent/lazyAgentProfileCard.js +5 -0
- package/dist/esm/components/common/PopupTrigger.js +44 -0
- package/dist/esm/components/common/ProfileCardTrigger.js +84 -0
- package/dist/esm/components/common/types.js +1 -0
- package/dist/esm/util/analytics.js +5 -1
- package/dist/types/client/RovoAgentCardClient.d.ts +9 -0
- package/dist/types/client/getAgentInfo.d.ts +3 -0
- package/dist/types/components/Agent/AgentProfileCard.d.ts +6 -0
- package/dist/types/components/Agent/AgentProfileCardTrigger.d.ts +3 -0
- package/dist/types/components/Agent/lazyAgentProfileCard.d.ts +4 -0
- package/dist/types/components/common/PopupTrigger.d.ts +8 -0
- package/dist/types/components/common/ProfileCardTrigger.d.ts +4 -0
- package/dist/types/components/common/types.d.ts +10 -0
- package/dist/types/types.d.ts +4 -0
- package/dist/types/util/analytics.d.ts +3 -0
- package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +9 -0
- package/dist/types-ts4.5/client/getAgentInfo.d.ts +3 -0
- package/dist/types-ts4.5/components/Agent/AgentProfileCard.d.ts +6 -0
- package/dist/types-ts4.5/components/Agent/AgentProfileCardTrigger.d.ts +3 -0
- package/dist/types-ts4.5/components/Agent/lazyAgentProfileCard.d.ts +4 -0
- package/dist/types-ts4.5/components/common/PopupTrigger.d.ts +8 -0
- package/dist/types-ts4.5/components/common/ProfileCardTrigger.d.ts +4 -0
- package/dist/types-ts4.5/components/common/types.d.ts +10 -0
- package/dist/types-ts4.5/types.d.ts +4 -0
- package/dist/types-ts4.5/util/analytics.d.ts +3 -0
- package/package.json +17 -17
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Popup from '@atlaskit/popup';
|
|
4
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
5
|
+
import { PopupTrigger } from './PopupTrigger';
|
|
6
|
+
const DELAY_MS_SHOW = 800;
|
|
7
|
+
const DELAY_MS_HIDE = 200;
|
|
8
|
+
function ProfileCardTrigger({
|
|
9
|
+
trigger,
|
|
10
|
+
ariaLabelledBy,
|
|
11
|
+
children,
|
|
12
|
+
renderProfileCard,
|
|
13
|
+
fetchProfile,
|
|
14
|
+
disabledAriaAttributes,
|
|
15
|
+
...popupProps
|
|
16
|
+
}) {
|
|
17
|
+
var _popupProps$autoFocus;
|
|
18
|
+
const showDelay = trigger === 'click' ? 0 : DELAY_MS_SHOW;
|
|
19
|
+
const hideDelay = trigger === 'click' ? 0 : DELAY_MS_HIDE;
|
|
20
|
+
const showTimer = useRef(0);
|
|
21
|
+
const hideTimer = useRef(0);
|
|
22
|
+
const [visible, setVisible] = useState(false);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
return () => {
|
|
25
|
+
clearTimeout(showTimer.current);
|
|
26
|
+
clearTimeout(hideTimer.current);
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
const hideProfilecard = useCallback(() => {
|
|
30
|
+
clearTimeout(showTimer.current);
|
|
31
|
+
clearTimeout(hideTimer.current);
|
|
32
|
+
hideTimer.current = window.setTimeout(() => {
|
|
33
|
+
setVisible(false);
|
|
34
|
+
}, hideDelay);
|
|
35
|
+
}, [hideDelay]);
|
|
36
|
+
const showProfilecard = useCallback(() => {
|
|
37
|
+
clearTimeout(hideTimer.current);
|
|
38
|
+
clearTimeout(showTimer.current);
|
|
39
|
+
showTimer.current = window.setTimeout(() => {
|
|
40
|
+
if (!visible) {
|
|
41
|
+
void (fetchProfile === null || fetchProfile === void 0 ? void 0 : fetchProfile());
|
|
42
|
+
setVisible(true);
|
|
43
|
+
}
|
|
44
|
+
}, showDelay);
|
|
45
|
+
}, [showDelay, visible, fetchProfile]);
|
|
46
|
+
const onMouseEnter = useCallback(() => {
|
|
47
|
+
showProfilecard();
|
|
48
|
+
}, [showProfilecard]);
|
|
49
|
+
return /*#__PURE__*/React.createElement(Popup, _extends({}, popupProps, {
|
|
50
|
+
isOpen: !!visible,
|
|
51
|
+
onClose: hideProfilecard,
|
|
52
|
+
shouldUseCaptureOnOutsideClick: true,
|
|
53
|
+
autoFocus: (_popupProps$autoFocus = popupProps.autoFocus) !== null && _popupProps$autoFocus !== void 0 ? _popupProps$autoFocus : trigger === 'click',
|
|
54
|
+
zIndex: layers.modal(),
|
|
55
|
+
shouldFitContainer: false,
|
|
56
|
+
trigger: triggerProps => {
|
|
57
|
+
const {
|
|
58
|
+
'aria-expanded': _,
|
|
59
|
+
'aria-haspopup': __,
|
|
60
|
+
...restInnerProps
|
|
61
|
+
} = triggerProps;
|
|
62
|
+
return /*#__PURE__*/React.createElement(PopupTrigger, _extends({}, disabledAriaAttributes ? restInnerProps : triggerProps, {
|
|
63
|
+
forwardRef: triggerProps.ref,
|
|
64
|
+
hideProfilecard: hideProfilecard,
|
|
65
|
+
showProfilecard: showProfilecard,
|
|
66
|
+
children: children,
|
|
67
|
+
ariaLabelledBy: ariaLabelledBy,
|
|
68
|
+
trigger: trigger
|
|
69
|
+
}));
|
|
70
|
+
},
|
|
71
|
+
content: () => /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
onMouseEnter: onMouseEnter,
|
|
73
|
+
onMouseLeave: hideProfilecard,
|
|
74
|
+
onFocus: showProfilecard
|
|
75
|
+
}, renderProfileCard())
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
export default ProfileCardTrigger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -24,6 +24,7 @@ export const fireEvent = (createAnalyticsEvent, body) => {
|
|
|
24
24
|
|
|
25
25
|
const TEAM_SUBJECT = 'teamProfileCard';
|
|
26
26
|
const USER_SUBJECT = 'profilecard';
|
|
27
|
+
const RovoAgent = 'rovoAgenrProfilecard';
|
|
27
28
|
const createEvent = (eventType, action, actionSubject, actionSubjectId, attributes = {}) => ({
|
|
28
29
|
eventType,
|
|
29
30
|
action,
|
|
@@ -31,7 +32,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
|
|
|
31
32
|
actionSubjectId,
|
|
32
33
|
attributes: {
|
|
33
34
|
packageName: "@atlaskit/profilecard",
|
|
34
|
-
packageVersion: "19.17.
|
|
35
|
+
packageVersion: "19.17.4",
|
|
35
36
|
...attributes,
|
|
36
37
|
firedAt: Math.round(getPageTime())
|
|
37
38
|
}
|
|
@@ -47,4 +48,5 @@ export const reportingLinesClicked = attributes => createEvent('ui', 'clicked',
|
|
|
47
48
|
export const moreActionsClicked = (type, attributes) => createEvent('ui', 'clicked', type === 'user' ? USER_SUBJECT : TEAM_SUBJECT, 'moreActions', attributes);
|
|
48
49
|
export const teamAvatarClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'avatar', attributes);
|
|
49
50
|
export const moreMembersClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'moreMembers', attributes);
|
|
50
|
-
export const errorRetryClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'errorRetry', attributes);
|
|
51
|
+
export const errorRetryClicked = attributes => createEvent('ui', 'clicked', TEAM_SUBJECT, 'errorRetry', attributes);
|
|
52
|
+
export const agentRequestAnalytics = (action, attributes) => createEvent('operational', action, RovoAgent, 'request', attributes);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
+
import { agentRequestAnalytics } from '../util/analytics';
|
|
12
|
+
import { getPageTime } from '../util/performance';
|
|
13
|
+
import CachingClient from './CachingClient';
|
|
14
|
+
import { getErrorAttributes } from './errorUtils';
|
|
15
|
+
import { getAgentDetailsByAgentId } from './getAgentInfo';
|
|
16
|
+
var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
17
|
+
_inherits(RovoAgentCardClient, _CachingClient);
|
|
18
|
+
var _super = _createSuper(RovoAgentCardClient);
|
|
19
|
+
function RovoAgentCardClient(options) {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, RovoAgentCardClient);
|
|
22
|
+
_this = _super.call(this, options);
|
|
23
|
+
_this.options = options;
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
_createClass(RovoAgentCardClient, [{
|
|
27
|
+
key: "makeRequest",
|
|
28
|
+
value: function makeRequest(agentId) {
|
|
29
|
+
if (!this.options.productIdentifier) {
|
|
30
|
+
throw new Error('Trying to fetch agents data with no specified config.productIdentifier');
|
|
31
|
+
}
|
|
32
|
+
return getAgentDetailsByAgentId(agentId, this.options.productIdentifier);
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
key: "getProfile",
|
|
36
|
+
value: function getProfile(agentId, analytics) {
|
|
37
|
+
var _this2 = this;
|
|
38
|
+
if (!agentId) {
|
|
39
|
+
return Promise.reject(new Error('agentId is missing'));
|
|
40
|
+
}
|
|
41
|
+
var cache = this.getCachedProfile(agentId);
|
|
42
|
+
if (cache) {
|
|
43
|
+
return Promise.resolve(cache);
|
|
44
|
+
}
|
|
45
|
+
return new Promise(function (resolve, reject) {
|
|
46
|
+
var startTime = getPageTime();
|
|
47
|
+
if (analytics) {
|
|
48
|
+
analytics(agentRequestAnalytics('triggered'));
|
|
49
|
+
}
|
|
50
|
+
_this2.makeRequest(agentId).then(function (data) {
|
|
51
|
+
if (_this2.cache) {
|
|
52
|
+
_this2.setCachedProfile(agentId, data);
|
|
53
|
+
}
|
|
54
|
+
if (analytics) {
|
|
55
|
+
analytics(agentRequestAnalytics('succeeded', {
|
|
56
|
+
duration: getPageTime() - startTime,
|
|
57
|
+
gateway: true
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
resolve(data);
|
|
61
|
+
}).catch(function (error) {
|
|
62
|
+
if (analytics) {
|
|
63
|
+
analytics(agentRequestAnalytics('failed', _objectSpread(_objectSpread({
|
|
64
|
+
duration: getPageTime() - startTime
|
|
65
|
+
}, getErrorAttributes(error)), {}, {
|
|
66
|
+
gateway: true
|
|
67
|
+
})));
|
|
68
|
+
}
|
|
69
|
+
reject(error);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}]);
|
|
74
|
+
return RovoAgentCardClient;
|
|
75
|
+
}(CachingClient);
|
|
76
|
+
export { RovoAgentCardClient as default };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
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
|
+
var createHeaders = function createHeaders(product) {
|
|
7
|
+
var config = {
|
|
8
|
+
headers: {
|
|
9
|
+
'x-product': product,
|
|
10
|
+
'x-experience-id': 'profile-card'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
return new Headers(_objectSpread({}, config.headers || {}));
|
|
14
|
+
};
|
|
15
|
+
export function getAgentDetailsByAgentId(_x, _x2) {
|
|
16
|
+
return _getAgentDetailsByAgentId.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
function _getAgentDetailsByAgentId() {
|
|
19
|
+
_getAgentDetailsByAgentId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(agentId, product) {
|
|
20
|
+
var headers;
|
|
21
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
headers = createHeaders(product);
|
|
25
|
+
_context.next = 3;
|
|
26
|
+
return fetch(new Request("assist/agents/v1/".concat(agentId), {
|
|
27
|
+
method: 'GET',
|
|
28
|
+
credentials: 'include',
|
|
29
|
+
mode: 'cors',
|
|
30
|
+
headers: headers
|
|
31
|
+
})).then(function (response) {
|
|
32
|
+
return response.json();
|
|
33
|
+
});
|
|
34
|
+
case 3:
|
|
35
|
+
return _context.abrupt("return", _context.sent);
|
|
36
|
+
case 4:
|
|
37
|
+
case "end":
|
|
38
|
+
return _context.stop();
|
|
39
|
+
}
|
|
40
|
+
}, _callee);
|
|
41
|
+
}));
|
|
42
|
+
return _getAgentDetailsByAgentId.apply(this, arguments);
|
|
43
|
+
}
|
|
44
|
+
export function getAgentDetailsByUserId(_x3, _x4) {
|
|
45
|
+
return _getAgentDetailsByUserId.apply(this, arguments);
|
|
46
|
+
}
|
|
47
|
+
function _getAgentDetailsByUserId() {
|
|
48
|
+
_getAgentDetailsByUserId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(userId, product) {
|
|
49
|
+
var headers;
|
|
50
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
51
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
headers = createHeaders(product);
|
|
54
|
+
_context2.next = 3;
|
|
55
|
+
return fetch(new Request("assist/agents/v1/accountid/".concat(userId), {
|
|
56
|
+
method: 'GET',
|
|
57
|
+
credentials: 'include',
|
|
58
|
+
mode: 'cors',
|
|
59
|
+
headers: headers
|
|
60
|
+
})).then(function (response) {
|
|
61
|
+
return response.json();
|
|
62
|
+
});
|
|
63
|
+
case 3:
|
|
64
|
+
return _context2.abrupt("return", _context2.sent);
|
|
65
|
+
case 4:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context2.stop();
|
|
68
|
+
}
|
|
69
|
+
}, _callee2);
|
|
70
|
+
}));
|
|
71
|
+
return _getAgentDetailsByUserId.apply(this, arguments);
|
|
72
|
+
}
|
|
@@ -48,7 +48,7 @@ export var addHeaders = function addHeaders(headers) {
|
|
|
48
48
|
headers.append('X-ExperimentalApi', 'teams-beta');
|
|
49
49
|
headers.append('X-ExperimentalApi', 'team-members-beta');
|
|
50
50
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
51
|
-
headers.append('atl-client-version', "19.17.
|
|
51
|
+
headers.append('atl-client-version', "19.17.4");
|
|
52
52
|
return headers;
|
|
53
53
|
};
|
|
54
54
|
export function getTeamFromAGG(_x, _x2, _x3) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["trigger"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import ProfileCardTrigger from '../common/ProfileCardTrigger';
|
|
6
|
+
import { AgentProfileCardLazy } from './lazyAgentProfileCard';
|
|
7
|
+
export var AgentProfileCardTrigger = function AgentProfileCardTrigger(_ref) {
|
|
8
|
+
var _ref$trigger = _ref.trigger,
|
|
9
|
+
trigger = _ref$trigger === void 0 ? 'hover' : _ref$trigger,
|
|
10
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
11
|
+
var renderProfileCard = function renderProfileCard() {
|
|
12
|
+
return /*#__PURE__*/React.createElement(AgentProfileCardLazy, null);
|
|
13
|
+
};
|
|
14
|
+
return /*#__PURE__*/React.createElement(ProfileCardTrigger, _extends({}, props, {
|
|
15
|
+
renderProfileCard: renderProfileCard,
|
|
16
|
+
trigger: trigger
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["children", "trigger", "forwardRef", "showProfilecard", "hideProfilecard", "ariaLabelledBy"];
|
|
4
|
+
import React, { useCallback, useMemo } from 'react';
|
|
5
|
+
export var PopupTrigger = function PopupTrigger(_ref) {
|
|
6
|
+
var children = _ref.children,
|
|
7
|
+
trigger = _ref.trigger,
|
|
8
|
+
forwardRef = _ref.forwardRef,
|
|
9
|
+
showProfilecard = _ref.showProfilecard,
|
|
10
|
+
hideProfilecard = _ref.hideProfilecard,
|
|
11
|
+
ariaLabelledBy = _ref.ariaLabelledBy,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
var onMouseEnter = useCallback(function () {
|
|
14
|
+
showProfilecard();
|
|
15
|
+
}, [showProfilecard]);
|
|
16
|
+
var onKeyPress = useCallback(function (event) {
|
|
17
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
showProfilecard();
|
|
20
|
+
}
|
|
21
|
+
}, [showProfilecard]);
|
|
22
|
+
var onClick = useCallback(function (event) {
|
|
23
|
+
// If the user clicks on the trigger then we don't want that click event to
|
|
24
|
+
// propagate out to parent containers. For example when clicking a mention
|
|
25
|
+
// lozenge in an inline-edit.
|
|
26
|
+
event.stopPropagation();
|
|
27
|
+
showProfilecard();
|
|
28
|
+
}, [showProfilecard]);
|
|
29
|
+
var containerListeners = useMemo(function () {
|
|
30
|
+
return trigger === 'hover' ? {
|
|
31
|
+
onMouseEnter: onMouseEnter,
|
|
32
|
+
onMouseLeave: hideProfilecard,
|
|
33
|
+
onBlur: hideProfilecard,
|
|
34
|
+
onKeyPress: onKeyPress
|
|
35
|
+
} : {
|
|
36
|
+
onClick: onClick,
|
|
37
|
+
onKeyPress: onKeyPress
|
|
38
|
+
};
|
|
39
|
+
}, [hideProfilecard, onClick, onKeyPress, onMouseEnter, trigger]);
|
|
40
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, props, containerListeners, {
|
|
41
|
+
ref: forwardRef,
|
|
42
|
+
"aria-labelledby": ariaLabelledBy
|
|
43
|
+
}), children);
|
|
44
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["trigger", "ariaLabelledBy", "children", "renderProfileCard", "fetchProfile", "disabledAriaAttributes"],
|
|
5
|
+
_excluded2 = ["aria-expanded", "aria-haspopup"];
|
|
6
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
+
import Popup from '@atlaskit/popup';
|
|
8
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
9
|
+
import { PopupTrigger } from './PopupTrigger';
|
|
10
|
+
var DELAY_MS_SHOW = 800;
|
|
11
|
+
var DELAY_MS_HIDE = 200;
|
|
12
|
+
function ProfileCardTrigger(_ref) {
|
|
13
|
+
var _popupProps$autoFocus;
|
|
14
|
+
var _trigger = _ref.trigger,
|
|
15
|
+
ariaLabelledBy = _ref.ariaLabelledBy,
|
|
16
|
+
children = _ref.children,
|
|
17
|
+
renderProfileCard = _ref.renderProfileCard,
|
|
18
|
+
fetchProfile = _ref.fetchProfile,
|
|
19
|
+
disabledAriaAttributes = _ref.disabledAriaAttributes,
|
|
20
|
+
popupProps = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
var showDelay = _trigger === 'click' ? 0 : DELAY_MS_SHOW;
|
|
22
|
+
var hideDelay = _trigger === 'click' ? 0 : DELAY_MS_HIDE;
|
|
23
|
+
var showTimer = useRef(0);
|
|
24
|
+
var hideTimer = useRef(0);
|
|
25
|
+
var _useState = useState(false),
|
|
26
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
27
|
+
visible = _useState2[0],
|
|
28
|
+
setVisible = _useState2[1];
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
return function () {
|
|
31
|
+
clearTimeout(showTimer.current);
|
|
32
|
+
clearTimeout(hideTimer.current);
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
var hideProfilecard = useCallback(function () {
|
|
36
|
+
clearTimeout(showTimer.current);
|
|
37
|
+
clearTimeout(hideTimer.current);
|
|
38
|
+
hideTimer.current = window.setTimeout(function () {
|
|
39
|
+
setVisible(false);
|
|
40
|
+
}, hideDelay);
|
|
41
|
+
}, [hideDelay]);
|
|
42
|
+
var showProfilecard = useCallback(function () {
|
|
43
|
+
clearTimeout(hideTimer.current);
|
|
44
|
+
clearTimeout(showTimer.current);
|
|
45
|
+
showTimer.current = window.setTimeout(function () {
|
|
46
|
+
if (!visible) {
|
|
47
|
+
void (fetchProfile === null || fetchProfile === void 0 ? void 0 : fetchProfile());
|
|
48
|
+
setVisible(true);
|
|
49
|
+
}
|
|
50
|
+
}, showDelay);
|
|
51
|
+
}, [showDelay, visible, fetchProfile]);
|
|
52
|
+
var onMouseEnter = useCallback(function () {
|
|
53
|
+
showProfilecard();
|
|
54
|
+
}, [showProfilecard]);
|
|
55
|
+
return /*#__PURE__*/React.createElement(Popup, _extends({}, popupProps, {
|
|
56
|
+
isOpen: !!visible,
|
|
57
|
+
onClose: hideProfilecard,
|
|
58
|
+
shouldUseCaptureOnOutsideClick: true,
|
|
59
|
+
autoFocus: (_popupProps$autoFocus = popupProps.autoFocus) !== null && _popupProps$autoFocus !== void 0 ? _popupProps$autoFocus : _trigger === 'click',
|
|
60
|
+
zIndex: layers.modal(),
|
|
61
|
+
shouldFitContainer: false,
|
|
62
|
+
trigger: function trigger(triggerProps) {
|
|
63
|
+
var _ = triggerProps['aria-expanded'],
|
|
64
|
+
__ = triggerProps['aria-haspopup'],
|
|
65
|
+
restInnerProps = _objectWithoutProperties(triggerProps, _excluded2);
|
|
66
|
+
return /*#__PURE__*/React.createElement(PopupTrigger, _extends({}, disabledAriaAttributes ? restInnerProps : triggerProps, {
|
|
67
|
+
forwardRef: triggerProps.ref,
|
|
68
|
+
hideProfilecard: hideProfilecard,
|
|
69
|
+
showProfilecard: showProfilecard,
|
|
70
|
+
children: children,
|
|
71
|
+
ariaLabelledBy: ariaLabelledBy,
|
|
72
|
+
trigger: _trigger
|
|
73
|
+
}));
|
|
74
|
+
},
|
|
75
|
+
content: function content() {
|
|
76
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
onMouseEnter: onMouseEnter,
|
|
78
|
+
onMouseLeave: hideProfilecard,
|
|
79
|
+
onFocus: showProfilecard
|
|
80
|
+
}, renderProfileCard());
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
export default ProfileCardTrigger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -29,6 +29,7 @@ export var fireEvent = function fireEvent(createAnalyticsEvent, body) {
|
|
|
29
29
|
|
|
30
30
|
var TEAM_SUBJECT = 'teamProfileCard';
|
|
31
31
|
var USER_SUBJECT = 'profilecard';
|
|
32
|
+
var RovoAgent = 'rovoAgenrProfilecard';
|
|
32
33
|
var createEvent = function createEvent(eventType, action, actionSubject, actionSubjectId) {
|
|
33
34
|
var attributes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
34
35
|
return {
|
|
@@ -38,7 +39,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
38
39
|
actionSubjectId: actionSubjectId,
|
|
39
40
|
attributes: _objectSpread(_objectSpread({
|
|
40
41
|
packageName: "@atlaskit/profilecard",
|
|
41
|
-
packageVersion: "19.17.
|
|
42
|
+
packageVersion: "19.17.4"
|
|
42
43
|
}, attributes), {}, {
|
|
43
44
|
firedAt: Math.round(getPageTime())
|
|
44
45
|
})
|
|
@@ -75,4 +76,7 @@ export var moreMembersClicked = function moreMembersClicked(attributes) {
|
|
|
75
76
|
};
|
|
76
77
|
export var errorRetryClicked = function errorRetryClicked(attributes) {
|
|
77
78
|
return createEvent('ui', 'clicked', TEAM_SUBJECT, 'errorRetry', attributes);
|
|
79
|
+
};
|
|
80
|
+
export var agentRequestAnalytics = function agentRequestAnalytics(action, attributes) {
|
|
81
|
+
return createEvent('operational', action, RovoAgent, 'request', attributes);
|
|
78
82
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnalyticsEventPayload } from '@atlaskit/analytics-next';
|
|
2
|
+
import type { ProfileClientOptions, RovoAgent } from '../types';
|
|
3
|
+
import CachingClient from './CachingClient';
|
|
4
|
+
export default class RovoAgentCardClient extends CachingClient<RovoAgent> {
|
|
5
|
+
options: ProfileClientOptions;
|
|
6
|
+
constructor(options: ProfileClientOptions);
|
|
7
|
+
makeRequest(agentId: string): Promise<RovoAgent>;
|
|
8
|
+
getProfile(agentId: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<RovoAgent>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type TriggerProps } from '@atlaskit/popup';
|
|
3
|
+
import { type ProfileCardTriggerProps } from './types';
|
|
4
|
+
export declare const PopupTrigger: ({ children, trigger, forwardRef, showProfilecard, hideProfilecard, ariaLabelledBy, ...props }: Partial<TriggerProps> & {
|
|
5
|
+
showProfilecard: () => void;
|
|
6
|
+
hideProfilecard: () => void;
|
|
7
|
+
forwardRef: React.Ref<HTMLSpanElement>;
|
|
8
|
+
} & Pick<ProfileCardTriggerProps, "children" | "trigger" | "ariaLabelledBy">) => JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ProfileCardTriggerProps } from './types';
|
|
3
|
+
declare function ProfileCardTrigger<T>({ trigger, ariaLabelledBy, children, renderProfileCard, fetchProfile, disabledAriaAttributes, ...popupProps }: ProfileCardTriggerProps): JSX.Element;
|
|
4
|
+
export default ProfileCardTrigger;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type PopupProps } from '@atlaskit/popup';
|
|
3
|
+
export type ProfileCardTriggerProps = {
|
|
4
|
+
trigger: 'hover' | 'click';
|
|
5
|
+
ariaLabelledBy?: string;
|
|
6
|
+
disabledAriaAttributes?: boolean;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
renderProfileCard: () => React.ReactNode;
|
|
9
|
+
fetchProfile?: () => Promise<void>;
|
|
10
|
+
} & Omit<PopupProps, 'trigger' | 'isOpen' | 'content'>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -56,4 +56,7 @@ export declare const moreMembersClicked: (attributes: {
|
|
|
56
56
|
export declare const errorRetryClicked: (attributes: {
|
|
57
57
|
duration: number;
|
|
58
58
|
}) => AnalyticsEventPayload;
|
|
59
|
+
export declare const agentRequestAnalytics: (action: 'triggered' | 'succeeded' | 'failed', attributes?: {
|
|
60
|
+
duration: number;
|
|
61
|
+
} & GenericAttributes) => AnalyticsEventPayload;
|
|
59
62
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnalyticsEventPayload } from '@atlaskit/analytics-next';
|
|
2
|
+
import type { ProfileClientOptions, RovoAgent } from '../types';
|
|
3
|
+
import CachingClient from './CachingClient';
|
|
4
|
+
export default class RovoAgentCardClient extends CachingClient<RovoAgent> {
|
|
5
|
+
options: ProfileClientOptions;
|
|
6
|
+
constructor(options: ProfileClientOptions);
|
|
7
|
+
makeRequest(agentId: string): Promise<RovoAgent>;
|
|
8
|
+
getProfile(agentId: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<RovoAgent>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type TriggerProps } from '@atlaskit/popup';
|
|
3
|
+
import { type ProfileCardTriggerProps } from './types';
|
|
4
|
+
export declare const PopupTrigger: ({ children, trigger, forwardRef, showProfilecard, hideProfilecard, ariaLabelledBy, ...props }: Partial<TriggerProps> & {
|
|
5
|
+
showProfilecard: () => void;
|
|
6
|
+
hideProfilecard: () => void;
|
|
7
|
+
forwardRef: React.Ref<HTMLSpanElement>;
|
|
8
|
+
} & Pick<ProfileCardTriggerProps, "children" | "trigger" | "ariaLabelledBy">) => JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ProfileCardTriggerProps } from './types';
|
|
3
|
+
declare function ProfileCardTrigger<T>({ trigger, ariaLabelledBy, children, renderProfileCard, fetchProfile, disabledAriaAttributes, ...popupProps }: ProfileCardTriggerProps): JSX.Element;
|
|
4
|
+
export default ProfileCardTrigger;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type PopupProps } from '@atlaskit/popup';
|
|
3
|
+
export type ProfileCardTriggerProps = {
|
|
4
|
+
trigger: 'hover' | 'click';
|
|
5
|
+
ariaLabelledBy?: string;
|
|
6
|
+
disabledAriaAttributes?: boolean;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
renderProfileCard: () => React.ReactNode;
|
|
9
|
+
fetchProfile?: () => Promise<void>;
|
|
10
|
+
} & Omit<PopupProps, 'trigger' | 'isOpen' | 'content'>;
|
|
@@ -56,4 +56,7 @@ export declare const moreMembersClicked: (attributes: {
|
|
|
56
56
|
export declare const errorRetryClicked: (attributes: {
|
|
57
57
|
duration: number;
|
|
58
58
|
}) => AnalyticsEventPayload;
|
|
59
|
+
export declare const agentRequestAnalytics: (action: 'triggered' | 'succeeded' | 'failed', attributes?: {
|
|
60
|
+
duration: number;
|
|
61
|
+
} & GenericAttributes) => AnalyticsEventPayload;
|
|
59
62
|
export {};
|