@atlaskit/smart-user-picker 4.0.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 +140 -0
- package/LICENSE +13 -0
- package/build/tsconfig.json +16 -0
- package/dist/cjs/analytics.js +131 -0
- package/dist/cjs/components/MessagesIntlProvider.js +72 -0
- package/dist/cjs/components/SmartUserPicker.js +473 -0
- package/dist/cjs/components/index.js +24 -0
- package/dist/cjs/config/index.js +50 -0
- package/dist/cjs/i18n/cs.js +26 -0
- package/dist/cjs/i18n/da.js +26 -0
- package/dist/cjs/i18n/de.js +26 -0
- package/dist/cjs/i18n/en.js +14 -0
- package/dist/cjs/i18n/en_GB.js +14 -0
- package/dist/cjs/i18n/en_ZZ.js +26 -0
- package/dist/cjs/i18n/es.js +26 -0
- package/dist/cjs/i18n/et.js +16 -0
- package/dist/cjs/i18n/fi.js +26 -0
- package/dist/cjs/i18n/fr.js +26 -0
- package/dist/cjs/i18n/hu.js +26 -0
- package/dist/cjs/i18n/index.js +247 -0
- package/dist/cjs/i18n/is.js +14 -0
- package/dist/cjs/i18n/it.js +26 -0
- package/dist/cjs/i18n/ja.js +26 -0
- package/dist/cjs/i18n/ko.js +26 -0
- package/dist/cjs/i18n/languages.js +33 -0
- package/dist/cjs/i18n/nb.js +26 -0
- package/dist/cjs/i18n/nl.js +26 -0
- package/dist/cjs/i18n/pl.js +26 -0
- package/dist/cjs/i18n/pt_BR.js +26 -0
- package/dist/cjs/i18n/pt_PT.js +16 -0
- package/dist/cjs/i18n/ro.js +14 -0
- package/dist/cjs/i18n/ru.js +26 -0
- package/dist/cjs/i18n/sk.js +16 -0
- package/dist/cjs/i18n/sv.js +26 -0
- package/dist/cjs/i18n/th.js +26 -0
- package/dist/cjs/i18n/tr.js +26 -0
- package/dist/cjs/i18n/uk.js +26 -0
- package/dist/cjs/i18n/vi.js +26 -0
- package/dist/cjs/i18n/zh.js +26 -0
- package/dist/cjs/i18n/zh_TW.js +26 -0
- package/dist/cjs/i18n.js +57 -0
- package/dist/cjs/index.js +87 -0
- package/dist/cjs/service/constants.js +20 -0
- package/dist/cjs/service/default-value-hydration-client.js +278 -0
- package/dist/cjs/service/graphqlUtils.js +48 -0
- package/dist/cjs/service/index.js +23 -0
- package/dist/cjs/service/recommendation-client.js +71 -0
- package/dist/cjs/service/teams-client.js +56 -0
- package/dist/cjs/service/users-client.js +97 -0
- package/dist/cjs/service/users-transformer.js +94 -0
- package/dist/cjs/types.js +14 -0
- package/dist/cjs/ufoExperiences.js +39 -0
- package/dist/cjs/util/i18n-util.js +274 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/analytics.js +85 -0
- package/dist/es2019/components/MessagesIntlProvider.js +43 -0
- package/dist/es2019/components/SmartUserPicker.js +316 -0
- package/dist/es2019/components/index.js +11 -0
- package/dist/es2019/config/index.js +42 -0
- package/dist/es2019/i18n/cs.js +18 -0
- package/dist/es2019/i18n/da.js +18 -0
- package/dist/es2019/i18n/de.js +18 -0
- package/dist/es2019/i18n/en.js +7 -0
- package/dist/es2019/i18n/en_GB.js +7 -0
- package/dist/es2019/i18n/en_ZZ.js +18 -0
- package/dist/es2019/i18n/es.js +18 -0
- package/dist/es2019/i18n/et.js +8 -0
- package/dist/es2019/i18n/fi.js +18 -0
- package/dist/es2019/i18n/fr.js +18 -0
- package/dist/es2019/i18n/hu.js +18 -0
- package/dist/es2019/i18n/index.js +36 -0
- package/dist/es2019/i18n/is.js +7 -0
- package/dist/es2019/i18n/it.js +18 -0
- package/dist/es2019/i18n/ja.js +18 -0
- package/dist/es2019/i18n/ko.js +18 -0
- package/dist/es2019/i18n/languages.js +26 -0
- package/dist/es2019/i18n/nb.js +18 -0
- package/dist/es2019/i18n/nl.js +18 -0
- package/dist/es2019/i18n/pl.js +18 -0
- package/dist/es2019/i18n/pt_BR.js +18 -0
- package/dist/es2019/i18n/pt_PT.js +8 -0
- package/dist/es2019/i18n/ro.js +7 -0
- package/dist/es2019/i18n/ru.js +18 -0
- package/dist/es2019/i18n/sk.js +8 -0
- package/dist/es2019/i18n/sv.js +18 -0
- package/dist/es2019/i18n/th.js +18 -0
- package/dist/es2019/i18n/tr.js +18 -0
- package/dist/es2019/i18n/uk.js +18 -0
- package/dist/es2019/i18n/vi.js +18 -0
- package/dist/es2019/i18n/zh.js +18 -0
- package/dist/es2019/i18n/zh_TW.js +18 -0
- package/dist/es2019/i18n.js +48 -0
- package/dist/es2019/index.js +6 -0
- package/dist/es2019/service/constants.js +11 -0
- package/dist/es2019/service/default-value-hydration-client.js +125 -0
- package/dist/es2019/service/graphqlUtils.js +39 -0
- package/dist/es2019/service/index.js +2 -0
- package/dist/es2019/service/recommendation-client.js +52 -0
- package/dist/es2019/service/teams-client.js +37 -0
- package/dist/es2019/service/users-client.js +52 -0
- package/dist/es2019/service/users-transformer.js +73 -0
- package/dist/es2019/types.js +7 -0
- package/dist/es2019/ufoExperiences.js +26 -0
- package/dist/es2019/util/i18n-util.js +231 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/analytics.js +99 -0
- package/dist/esm/components/MessagesIntlProvider.js +50 -0
- package/dist/esm/components/SmartUserPicker.js +454 -0
- package/dist/esm/components/index.js +11 -0
- package/dist/esm/config/index.js +39 -0
- package/dist/esm/i18n/cs.js +18 -0
- package/dist/esm/i18n/da.js +18 -0
- package/dist/esm/i18n/de.js +18 -0
- package/dist/esm/i18n/en.js +7 -0
- package/dist/esm/i18n/en_GB.js +7 -0
- package/dist/esm/i18n/en_ZZ.js +18 -0
- package/dist/esm/i18n/es.js +18 -0
- package/dist/esm/i18n/et.js +8 -0
- package/dist/esm/i18n/fi.js +18 -0
- package/dist/esm/i18n/fr.js +18 -0
- package/dist/esm/i18n/hu.js +18 -0
- package/dist/esm/i18n/index.js +36 -0
- package/dist/esm/i18n/is.js +7 -0
- package/dist/esm/i18n/it.js +18 -0
- package/dist/esm/i18n/ja.js +18 -0
- package/dist/esm/i18n/ko.js +18 -0
- package/dist/esm/i18n/languages.js +26 -0
- package/dist/esm/i18n/nb.js +18 -0
- package/dist/esm/i18n/nl.js +18 -0
- package/dist/esm/i18n/pl.js +18 -0
- package/dist/esm/i18n/pt_BR.js +18 -0
- package/dist/esm/i18n/pt_PT.js +8 -0
- package/dist/esm/i18n/ro.js +7 -0
- package/dist/esm/i18n/ru.js +18 -0
- package/dist/esm/i18n/sk.js +8 -0
- package/dist/esm/i18n/sv.js +18 -0
- package/dist/esm/i18n/th.js +18 -0
- package/dist/esm/i18n/tr.js +18 -0
- package/dist/esm/i18n/uk.js +18 -0
- package/dist/esm/i18n/vi.js +18 -0
- package/dist/esm/i18n/zh.js +18 -0
- package/dist/esm/i18n/zh_TW.js +18 -0
- package/dist/esm/i18n.js +48 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/service/constants.js +11 -0
- package/dist/esm/service/default-value-hydration-client.js +261 -0
- package/dist/esm/service/graphqlUtils.js +41 -0
- package/dist/esm/service/index.js +2 -0
- package/dist/esm/service/recommendation-client.js +60 -0
- package/dist/esm/service/teams-client.js +45 -0
- package/dist/esm/service/users-client.js +83 -0
- package/dist/esm/service/users-transformer.js +83 -0
- package/dist/esm/types.js +7 -0
- package/dist/esm/ufoExperiences.js +26 -0
- package/dist/esm/util/i18n-util.js +256 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/analytics.d.ts +21 -0
- package/dist/types/components/MessagesIntlProvider.d.ts +9 -0
- package/dist/types/components/SmartUserPicker.d.ts +30 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/config/index.d.ts +9 -0
- package/dist/types/i18n/cs.d.ts +18 -0
- package/dist/types/i18n/da.d.ts +18 -0
- package/dist/types/i18n/de.d.ts +18 -0
- package/dist/types/i18n/en.d.ts +7 -0
- package/dist/types/i18n/en_GB.d.ts +7 -0
- package/dist/types/i18n/en_ZZ.d.ts +18 -0
- package/dist/types/i18n/es.d.ts +18 -0
- package/dist/types/i18n/et.d.ts +8 -0
- package/dist/types/i18n/fi.d.ts +18 -0
- package/dist/types/i18n/fr.d.ts +18 -0
- package/dist/types/i18n/hu.d.ts +18 -0
- package/dist/types/i18n/index.d.ts +36 -0
- package/dist/types/i18n/is.d.ts +7 -0
- package/dist/types/i18n/it.d.ts +18 -0
- package/dist/types/i18n/ja.d.ts +18 -0
- package/dist/types/i18n/ko.d.ts +18 -0
- package/dist/types/i18n/languages.d.ts +27 -0
- package/dist/types/i18n/nb.d.ts +18 -0
- package/dist/types/i18n/nl.d.ts +18 -0
- package/dist/types/i18n/pl.d.ts +18 -0
- package/dist/types/i18n/pt_BR.d.ts +18 -0
- package/dist/types/i18n/pt_PT.d.ts +8 -0
- package/dist/types/i18n/ro.d.ts +7 -0
- package/dist/types/i18n/ru.d.ts +18 -0
- package/dist/types/i18n/sk.d.ts +8 -0
- package/dist/types/i18n/sv.d.ts +18 -0
- package/dist/types/i18n/th.d.ts +18 -0
- package/dist/types/i18n/tr.d.ts +18 -0
- package/dist/types/i18n/uk.d.ts +18 -0
- package/dist/types/i18n/vi.d.ts +18 -0
- package/dist/types/i18n/zh.d.ts +18 -0
- package/dist/types/i18n/zh_TW.d.ts +18 -0
- package/dist/types/i18n.d.ts +47 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/service/constants.d.ts +4 -0
- package/dist/types/service/default-value-hydration-client.d.ts +8 -0
- package/dist/types/service/graphqlUtils.d.ts +14 -0
- package/dist/types/service/index.d.ts +2 -0
- package/dist/types/service/recommendation-client.d.ts +5 -0
- package/dist/types/service/teams-client.d.ts +12 -0
- package/dist/types/service/users-client.d.ts +11 -0
- package/dist/types/service/users-transformer.d.ts +22 -0
- package/dist/types/types.d.ts +208 -0
- package/dist/types/ufoExperiences.d.ts +3 -0
- package/dist/types/util/i18n-util.d.ts +11 -0
- package/docs/0-intro.tsx +52 -0
- package/package.json +56 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { UNKNOWN_USER } from './constants';
|
|
2
|
+
import { graphqlQuery } from './graphqlUtils';
|
|
3
|
+
import { getConfig } from '../config';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} accountIds ids to hydrate
|
|
7
|
+
* @return GraphQL Query
|
|
8
|
+
*/
|
|
9
|
+
const buildUsersQuery = accountIds => ({
|
|
10
|
+
query: `query usersQuery($accountIds: [ID!]!) {
|
|
11
|
+
users(accountIds: $accountIds) {
|
|
12
|
+
name
|
|
13
|
+
accountId
|
|
14
|
+
picture
|
|
15
|
+
}
|
|
16
|
+
}`,
|
|
17
|
+
variables: {
|
|
18
|
+
accountIds
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const makeRequest = async (url, accountIds) => {
|
|
23
|
+
const query = buildUsersQuery(accountIds);
|
|
24
|
+
return await graphqlQuery(url, query);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const modifyResponse = users => users.map(({
|
|
28
|
+
accountId,
|
|
29
|
+
name,
|
|
30
|
+
picture
|
|
31
|
+
}) => ({
|
|
32
|
+
avatarUrl: picture,
|
|
33
|
+
id: accountId,
|
|
34
|
+
name,
|
|
35
|
+
type: 'user'
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const getHydratedUsers = (baseUrl, userIds) => {
|
|
39
|
+
const url = getConfig().getGraphQLUrl(baseUrl);
|
|
40
|
+
return new Promise(resolve => {
|
|
41
|
+
makeRequest(url, userIds).then(data => {
|
|
42
|
+
resolve(modifyResponse(data.users));
|
|
43
|
+
}).catch(() => {
|
|
44
|
+
// on network error, return original list with label 'Unknown'
|
|
45
|
+
resolve(userIds.map(id => ({ ...UNKNOWN_USER,
|
|
46
|
+
id
|
|
47
|
+
})));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default getHydratedUsers;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { TeamType, UserType, GroupType } from '@atlaskit/user-picker';
|
|
2
|
+
import { messages } from '../i18n';
|
|
3
|
+
var EntityType;
|
|
4
|
+
|
|
5
|
+
(function (EntityType) {
|
|
6
|
+
EntityType["USER"] = "USER";
|
|
7
|
+
EntityType["TEAM"] = "TEAM";
|
|
8
|
+
EntityType["GROUP"] = "GROUP";
|
|
9
|
+
})(EntityType || (EntityType = {}));
|
|
10
|
+
|
|
11
|
+
const getLozenzeProperties = (entity, intl) => {
|
|
12
|
+
var _entity$attributes, _entity$attributes2;
|
|
13
|
+
|
|
14
|
+
if ((_entity$attributes = entity.attributes) !== null && _entity$attributes !== void 0 && _entity$attributes.workspaceMember) {
|
|
15
|
+
return intl.formatMessage(messages.memberLozengeText);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if ((_entity$attributes2 = entity.attributes) !== null && _entity$attributes2 !== void 0 && _entity$attributes2.isConfluenceExternalCollaborator) {
|
|
19
|
+
const lozengeTooltipMessage = entity.entityType === EntityType.GROUP ? messages.guestGroupLozengeTooltip : messages.guestUserLozengeTooltip;
|
|
20
|
+
return {
|
|
21
|
+
text: intl.formatMessage(messages.guestLozengeText),
|
|
22
|
+
tooltip: intl.formatMessage(lozengeTooltipMessage),
|
|
23
|
+
appearance: 'new'
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const transformUser = (item, intl) => {
|
|
31
|
+
const type = item.entityType;
|
|
32
|
+
|
|
33
|
+
if (type === EntityType.USER) {
|
|
34
|
+
const user = item;
|
|
35
|
+
const lozenge = getLozenzeProperties(user, intl);
|
|
36
|
+
return {
|
|
37
|
+
id: user.id,
|
|
38
|
+
type: UserType,
|
|
39
|
+
avatarUrl: user.avatarUrl,
|
|
40
|
+
name: user.name,
|
|
41
|
+
email: user.email,
|
|
42
|
+
lozenge: lozenge
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (type === EntityType.TEAM) {
|
|
47
|
+
const team = item;
|
|
48
|
+
return {
|
|
49
|
+
id: team.id,
|
|
50
|
+
type: TeamType,
|
|
51
|
+
description: team.description || '',
|
|
52
|
+
name: team.displayName || '',
|
|
53
|
+
memberCount: team.memberCount,
|
|
54
|
+
includesYou: team.includesYou,
|
|
55
|
+
avatarUrl: team.largeAvatarImageUrl || team.smallAvatarImageUrl
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (type === EntityType.GROUP) {
|
|
60
|
+
const group = item;
|
|
61
|
+
const lozenge = getLozenzeProperties(group, intl);
|
|
62
|
+
return {
|
|
63
|
+
id: group.id,
|
|
64
|
+
type: GroupType,
|
|
65
|
+
name: group.name || '',
|
|
66
|
+
lozenge: lozenge
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const transformUsers = (serverResponse, intl) => (serverResponse.recommendedUsers || []).map(item => transformUser(item, intl)).filter(user => !!user).map(user => user);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ExperiencePerformanceTypes, ExperienceTypes, ConcurrentExperience } from '@atlaskit/ufo';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
const COMPONENT_NAME = 'smart-user-picker';
|
|
4
|
+
export const smartUserPickerRenderedUfoExperience = new ConcurrentExperience('smart-user-picker-rendered', {
|
|
5
|
+
platform: {
|
|
6
|
+
component: COMPONENT_NAME
|
|
7
|
+
},
|
|
8
|
+
type: ExperienceTypes.Load,
|
|
9
|
+
performanceType: ExperiencePerformanceTypes.PageSegmentLoad
|
|
10
|
+
});
|
|
11
|
+
export const useUFOConcurrentExperience = (experience, id) => {
|
|
12
|
+
const experienceForId = experience.getInstance(id); // Equivalent to componentWillMount - replace with @atlaskit/ufo's
|
|
13
|
+
// useUFOComponentExperience when it supports ConcurrentExperience.
|
|
14
|
+
|
|
15
|
+
useState(() => {
|
|
16
|
+
experienceForId.start();
|
|
17
|
+
}); // Replace with @atlaskit/ufo's <ExperienceSuccess> when it supports ConcurrentExperience
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
experienceForId.success();
|
|
21
|
+
return () => {
|
|
22
|
+
experienceForId.abort();
|
|
23
|
+
}; // We only want this useEffect to run once after component mount, so no deps are needed.
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
|
+
}, []);
|
|
26
|
+
};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tries to get the most specific messages bundle for a given locale.
|
|
3
|
+
*
|
|
4
|
+
* Strategy:
|
|
5
|
+
* 1. Try to find messages with the exact string (i.e. 'fr_FR')
|
|
6
|
+
* 2. If that doesn't work, try to find messages for the country locale (i.e. 'fr')
|
|
7
|
+
* 3. If that doesn't work, return english messages as a fallback.
|
|
8
|
+
*
|
|
9
|
+
* @param locale string specifying the locale like 'en_GB', or 'fr'.
|
|
10
|
+
*/
|
|
11
|
+
export const getMessagesForLocale = async locale => {
|
|
12
|
+
switch (locale) {
|
|
13
|
+
case 'cs':
|
|
14
|
+
{
|
|
15
|
+
return import(
|
|
16
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-cs" */
|
|
17
|
+
'../i18n/cs').then(mod => mod.default);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
case 'da':
|
|
21
|
+
{
|
|
22
|
+
return import(
|
|
23
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-da" */
|
|
24
|
+
'../i18n/da').then(mod => mod.default);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
case 'de':
|
|
28
|
+
{
|
|
29
|
+
return import(
|
|
30
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-de" */
|
|
31
|
+
'../i18n/de').then(mod => mod.default);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
case 'en':
|
|
35
|
+
{
|
|
36
|
+
return import(
|
|
37
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-en" */
|
|
38
|
+
'../i18n/en').then(mod => mod.default);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
case 'en_GB':
|
|
42
|
+
{
|
|
43
|
+
return import(
|
|
44
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-en_GB" */
|
|
45
|
+
'../i18n/en_GB').then(mod => mod.default);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case 'es':
|
|
49
|
+
{
|
|
50
|
+
return import(
|
|
51
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-es" */
|
|
52
|
+
'../i18n/es').then(mod => mod.default);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
case 'et':
|
|
56
|
+
{
|
|
57
|
+
return import(
|
|
58
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-et" */
|
|
59
|
+
'../i18n/et').then(mod => mod.default);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
case 'fi':
|
|
63
|
+
{
|
|
64
|
+
return import(
|
|
65
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-fi" */
|
|
66
|
+
'../i18n/fi').then(mod => mod.default);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
case 'fr':
|
|
70
|
+
{
|
|
71
|
+
return import(
|
|
72
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-fr" */
|
|
73
|
+
'../i18n/fr').then(mod => mod.default);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
case 'hu':
|
|
77
|
+
{
|
|
78
|
+
return import(
|
|
79
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-hu" */
|
|
80
|
+
'../i18n/hu').then(mod => mod.default);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
case 'is':
|
|
84
|
+
{
|
|
85
|
+
return import(
|
|
86
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-is" */
|
|
87
|
+
'../i18n/is').then(mod => mod.default);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
case 'it':
|
|
91
|
+
{
|
|
92
|
+
return import(
|
|
93
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-it" */
|
|
94
|
+
'../i18n/it').then(mod => mod.default);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
case 'ja':
|
|
98
|
+
{
|
|
99
|
+
return import(
|
|
100
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-ja" */
|
|
101
|
+
'../i18n/ja').then(mod => mod.default);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
case 'ko':
|
|
105
|
+
{
|
|
106
|
+
return import(
|
|
107
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-ko" */
|
|
108
|
+
'../i18n/ko').then(mod => mod.default);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
case 'nb':
|
|
112
|
+
{
|
|
113
|
+
return import(
|
|
114
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-nb" */
|
|
115
|
+
'../i18n/nb').then(mod => mod.default);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case 'nl':
|
|
119
|
+
{
|
|
120
|
+
return import(
|
|
121
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-nl" */
|
|
122
|
+
'../i18n/nl').then(mod => mod.default);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
case 'pl':
|
|
126
|
+
{
|
|
127
|
+
return import(
|
|
128
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-pl" */
|
|
129
|
+
'../i18n/pl').then(mod => mod.default);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
case 'pt_BR':
|
|
133
|
+
case 'pt-BR':
|
|
134
|
+
{
|
|
135
|
+
return import(
|
|
136
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-pt_BR" */
|
|
137
|
+
'../i18n/pt_BR').then(mod => mod.default);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
case 'pt_PT':
|
|
141
|
+
case 'pt-PT':
|
|
142
|
+
{
|
|
143
|
+
return import(
|
|
144
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-pt_PT" */
|
|
145
|
+
'../i18n/pt_PT').then(mod => mod.default);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
case 'ro':
|
|
149
|
+
{
|
|
150
|
+
return import(
|
|
151
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-ro" */
|
|
152
|
+
'../i18n/ro').then(mod => mod.default);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
case 'ru':
|
|
156
|
+
{
|
|
157
|
+
return import(
|
|
158
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-ru" */
|
|
159
|
+
'../i18n/ru').then(mod => mod.default);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
case 'sk':
|
|
163
|
+
{
|
|
164
|
+
return import(
|
|
165
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-sk" */
|
|
166
|
+
'../i18n/sk').then(mod => mod.default);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
case 'sv':
|
|
170
|
+
{
|
|
171
|
+
return import(
|
|
172
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-sv" */
|
|
173
|
+
'../i18n/sv').then(mod => mod.default);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
case 'th':
|
|
177
|
+
{
|
|
178
|
+
return import(
|
|
179
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-th" */
|
|
180
|
+
'../i18n/th').then(mod => mod.default);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
case 'tr':
|
|
184
|
+
{
|
|
185
|
+
return import(
|
|
186
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-tr" */
|
|
187
|
+
'../i18n/tr').then(mod => mod.default);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
case 'uk':
|
|
191
|
+
{
|
|
192
|
+
return import(
|
|
193
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-uk" */
|
|
194
|
+
'../i18n/uk').then(mod => mod.default);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
case 'vi':
|
|
198
|
+
{
|
|
199
|
+
return import(
|
|
200
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-vi" */
|
|
201
|
+
'../i18n/vi').then(mod => mod.default);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
case 'zh_TW':
|
|
205
|
+
{
|
|
206
|
+
return import(
|
|
207
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-zh_TW" */
|
|
208
|
+
'../i18n/zh_TW').then(mod => mod.default);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
case 'zh':
|
|
212
|
+
{
|
|
213
|
+
return import(
|
|
214
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-zh" */
|
|
215
|
+
'../i18n/zh').then(mod => mod.default);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
default:
|
|
219
|
+
{
|
|
220
|
+
const fragments = locale.split(/[_-]/);
|
|
221
|
+
|
|
222
|
+
if (fragments.length === 2) {
|
|
223
|
+
return getMessagesForLocale(fragments[0]);
|
|
224
|
+
} else {
|
|
225
|
+
return import(
|
|
226
|
+
/* webpackChunkName: "@atlaskit-internal_user-picker-i18n-en" */
|
|
227
|
+
'../i18n/en').then(mod => mod.default);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
8
|
+
import { v4 as uuid } from 'uuid';
|
|
9
|
+
import { name as packageName, version as packageVersion } from './version.json';
|
|
10
|
+
export var startSession = function startSession() {
|
|
11
|
+
return {
|
|
12
|
+
id: uuid(),
|
|
13
|
+
start: Date.now(),
|
|
14
|
+
inputChangeTime: Date.now(),
|
|
15
|
+
upCount: 0,
|
|
16
|
+
downCount: 0,
|
|
17
|
+
lastKey: undefined
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export var createAndFireEventInElementsChannel = createAndFireEvent('fabric-elements');
|
|
21
|
+
|
|
22
|
+
var createEvent = function createEvent(eventType, action, actionSubject) {
|
|
23
|
+
var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
24
|
+
return {
|
|
25
|
+
eventType: eventType,
|
|
26
|
+
action: action,
|
|
27
|
+
actionSubject: actionSubject,
|
|
28
|
+
attributes: _objectSpread({
|
|
29
|
+
packageName: packageName,
|
|
30
|
+
packageVersion: packageVersion
|
|
31
|
+
}, attributes)
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var createDefaultSmartPickerAttributes = function createDefaultSmartPickerAttributes(props, state) {
|
|
36
|
+
var fieldId = props.fieldId,
|
|
37
|
+
objectId = props.objectId,
|
|
38
|
+
containerId = props.containerId,
|
|
39
|
+
childObjectId = props.childObjectId,
|
|
40
|
+
prefetch = props.prefetch,
|
|
41
|
+
maxOptions = props.maxOptions,
|
|
42
|
+
includeTeams = props.includeTeams,
|
|
43
|
+
productKey = props.productKey,
|
|
44
|
+
principalId = props.principalId,
|
|
45
|
+
siteId = props.siteId,
|
|
46
|
+
orgId = props.orgId,
|
|
47
|
+
filterOptions = props.filterOptions;
|
|
48
|
+
var sessionId = state.sessionId,
|
|
49
|
+
query = state.query;
|
|
50
|
+
var maxNumberOfResults = maxOptions || 100;
|
|
51
|
+
return {
|
|
52
|
+
context: fieldId,
|
|
53
|
+
childObjectId: childObjectId,
|
|
54
|
+
containerId: containerId,
|
|
55
|
+
hasFilterOptions: Boolean(filterOptions),
|
|
56
|
+
includeTeams: includeTeams,
|
|
57
|
+
maxNumberOfResults: maxNumberOfResults,
|
|
58
|
+
objectId: objectId,
|
|
59
|
+
prefetch: prefetch,
|
|
60
|
+
principalId: principalId,
|
|
61
|
+
productKey: productKey,
|
|
62
|
+
queryLength: (query || '').length,
|
|
63
|
+
siteId: siteId,
|
|
64
|
+
orgId: orgId,
|
|
65
|
+
sessionId: sessionId
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
var createSmartUserPickerEvent = function createSmartUserPickerEvent(action, actionSubect) {
|
|
70
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
71
|
+
return _objectSpread({
|
|
72
|
+
source: 'smart-user-picker'
|
|
73
|
+
}, createEvent('operational', action, actionSubect, attributes));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export var preparedUsersLoadedEvent = function preparedUsersLoadedEvent(props, state) {
|
|
77
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
78
|
+
return createSmartUserPickerEvent('loaded', 'preparedUsers', _objectSpread(_objectSpread({}, createDefaultSmartPickerAttributes(props, state)), attributes));
|
|
79
|
+
};
|
|
80
|
+
export var mountedWithPrefetchEvent = function mountedWithPrefetchEvent(props, state) {
|
|
81
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
82
|
+
return createSmartUserPickerEvent('mounted', 'prefetch', _objectSpread(_objectSpread({}, createDefaultSmartPickerAttributes(props, state)), attributes));
|
|
83
|
+
};
|
|
84
|
+
export var filterUsersEvent = function filterUsersEvent(props, state) {
|
|
85
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
86
|
+
return createSmartUserPickerEvent('filtered', 'users', _objectSpread(_objectSpread({}, createDefaultSmartPickerAttributes(props, state)), attributes));
|
|
87
|
+
};
|
|
88
|
+
export var requestUsersEvent = function requestUsersEvent(props, state) {
|
|
89
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
90
|
+
return createSmartUserPickerEvent('requested', 'users', _objectSpread(_objectSpread({}, createDefaultSmartPickerAttributes(props, state)), attributes));
|
|
91
|
+
};
|
|
92
|
+
export var successfulRequestUsersEvent = function successfulRequestUsersEvent(props, state) {
|
|
93
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
94
|
+
return createSmartUserPickerEvent('successful', 'usersRequest', _objectSpread(_objectSpread({}, createDefaultSmartPickerAttributes(props, state)), attributes));
|
|
95
|
+
};
|
|
96
|
+
export var failedRequestUsersEvent = function failedRequestUsersEvent(props, state) {
|
|
97
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
98
|
+
return createSmartUserPickerEvent('failed', 'usersRequest', _objectSpread(_objectSpread({}, createDefaultSmartPickerAttributes(props, state)), attributes));
|
|
99
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
|
|
8
|
+
import React, { useMemo } from 'react';
|
|
9
|
+
import { IntlProvider, injectIntl } from 'react-intl-next';
|
|
10
|
+
import { getMessagesForLocale } from '../util/i18n-util';
|
|
11
|
+
var EMPTY = {};
|
|
12
|
+
|
|
13
|
+
var useI18n = function useI18n(locale) {
|
|
14
|
+
var _React$useState = React.useState(EMPTY),
|
|
15
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
16
|
+
messages = _React$useState2[0],
|
|
17
|
+
setMessages = _React$useState2[1];
|
|
18
|
+
|
|
19
|
+
React.useEffect(function () {
|
|
20
|
+
var aborted = false;
|
|
21
|
+
setMessages(EMPTY);
|
|
22
|
+
getMessagesForLocale(locale).then(function (messages) {
|
|
23
|
+
if (!aborted) {
|
|
24
|
+
setMessages(messages);
|
|
25
|
+
}
|
|
26
|
+
}).catch(function (error) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.error(error);
|
|
29
|
+
});
|
|
30
|
+
return function () {
|
|
31
|
+
aborted = true;
|
|
32
|
+
};
|
|
33
|
+
}, [locale]);
|
|
34
|
+
return messages;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var MessagesIntlProvider = function MessagesIntlProvider(props) {
|
|
38
|
+
var intl = props.intl,
|
|
39
|
+
children = props.children;
|
|
40
|
+
var messages = useI18n(intl.locale);
|
|
41
|
+
var mergedMessages = useMemo(function () {
|
|
42
|
+
return _objectSpread(_objectSpread({}, intl.messages), messages);
|
|
43
|
+
}, [intl.messages, messages]);
|
|
44
|
+
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
45
|
+
locale: intl.locale,
|
|
46
|
+
messages: mergedMessages
|
|
47
|
+
}, children);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default injectIntl(MessagesIntlProvider);
|