@atlaskit/link-picker 1.16.9 → 1.16.10
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 +6 -0
- package/dist/cjs/analytics.codegen.js +1 -2
- package/dist/cjs/common/analytics/context.js +11 -36
- package/dist/cjs/common/analytics/experiences.js +0 -13
- package/dist/cjs/common/analytics/index.js +0 -2
- package/dist/cjs/common/analytics/input-field-tracking.js +16 -35
- package/dist/cjs/common/generic-error-svg/index.js +1 -7
- package/dist/cjs/common/generic-error-svg/styled.js +0 -6
- package/dist/cjs/common/utils/errors.js +0 -15
- package/dist/cjs/controllers/session-provider/index.js +1 -17
- package/dist/cjs/controllers/use-fix-height/index.js +0 -3
- package/dist/cjs/i18n/cs.js +0 -1
- package/dist/cjs/i18n/da.js +0 -1
- package/dist/cjs/i18n/de.js +0 -1
- package/dist/cjs/i18n/en.js +0 -1
- package/dist/cjs/i18n/en_GB.js +0 -1
- package/dist/cjs/i18n/es.js +0 -1
- package/dist/cjs/i18n/fi.js +0 -1
- package/dist/cjs/i18n/fr.js +0 -1
- package/dist/cjs/i18n/hu.js +0 -1
- package/dist/cjs/i18n/it.js +0 -1
- package/dist/cjs/i18n/ja.js +0 -1
- package/dist/cjs/i18n/ko.js +0 -1
- package/dist/cjs/i18n/nb.js +0 -1
- package/dist/cjs/i18n/nl.js +0 -1
- package/dist/cjs/i18n/pl.js +0 -1
- package/dist/cjs/i18n/pt_BR.js +0 -1
- package/dist/cjs/i18n/ru.js +0 -1
- package/dist/cjs/i18n/sv.js +0 -1
- package/dist/cjs/i18n/th.js +0 -1
- package/dist/cjs/i18n/tr.js +0 -1
- package/dist/cjs/i18n/uk.js +0 -1
- package/dist/cjs/i18n/vi.js +0 -1
- package/dist/cjs/i18n/zh.js +0 -1
- package/dist/cjs/i18n/zh_TW.js +0 -1
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/services/use-plugins/index.js +13 -44
- package/dist/cjs/services/use-plugins/reducer.js +0 -13
- package/dist/cjs/services/use-plugins/utils.js +9 -35
- package/dist/cjs/services/use-search-query/index.js +3 -9
- package/dist/cjs/ui/error-boundary/error-boundary-base/index.js +2 -22
- package/dist/cjs/ui/error-boundary/error-boundary-fallback/index.js +1 -9
- package/dist/cjs/ui/error-boundary/index.js +3 -18
- package/dist/cjs/ui/index.js +0 -13
- package/dist/cjs/ui/link-picker/announcer.js +15 -25
- package/dist/cjs/ui/link-picker/browser.js +0 -1
- package/dist/cjs/ui/link-picker/form-footer/index.js +6 -26
- package/dist/cjs/ui/link-picker/form-footer/styled.js +0 -5
- package/dist/cjs/ui/link-picker/form-footer/utils.js +2 -8
- package/dist/cjs/ui/link-picker/index.js +44 -111
- package/dist/cjs/ui/link-picker/link-search-error/index.js +1 -10
- package/dist/cjs/ui/link-picker/link-search-list/index.js +12 -38
- package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/index.js +1 -9
- package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/index.js +1 -5
- package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/styled.js +0 -6
- package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/styled.js +0 -5
- package/dist/cjs/ui/link-picker/link-search-list/styled.js +0 -7
- package/dist/cjs/ui/link-picker/link-search-list/use-track-results-shown/index.js +11 -21
- package/dist/cjs/ui/link-picker/list-item/index.js +11 -32
- package/dist/cjs/ui/link-picker/list-item/styled.js +0 -13
- package/dist/cjs/ui/link-picker/messages.js +0 -2
- package/dist/cjs/ui/link-picker/styled.js +1 -8
- package/dist/cjs/ui/link-picker/text-input/index.js +9 -26
- package/dist/cjs/ui/link-picker/text-input/styled.js +0 -7
- package/dist/cjs/ui/link-picker/track-mount/index.js +1 -11
- package/dist/cjs/ui/link-picker/track-tab-viewed/index.js +2 -10
- package/dist/cjs/ui/link-picker/transformTimeStamp.js +0 -13
- package/dist/cjs/ui/link-picker/utils.js +11 -19
- package/dist/cjs/ui/loader-fallback/index.js +1 -5
- package/dist/cjs/ui/scrolling-tabs/index.js +6 -44
- package/dist/cjs/ui/scrolling-tabs/scrolling-tabs.js +4 -33
- package/dist/cjs/ui/scrolling-tabs/styles.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics.codegen.js +1 -1
- package/dist/es2019/common/analytics/context.js +11 -13
- package/dist/es2019/common/analytics/experiences.js +0 -1
- package/dist/es2019/common/analytics/input-field-tracking.js +13 -12
- package/dist/es2019/common/generic-error-svg/index.js +0 -4
- package/dist/es2019/common/utils/errors.js +0 -1
- package/dist/es2019/controllers/session-provider/index.js +0 -4
- package/dist/es2019/controllers/use-fix-height/index.js +0 -2
- package/dist/es2019/services/use-plugins/index.js +2 -8
- package/dist/es2019/services/use-plugins/reducer.js +8 -8
- package/dist/es2019/services/use-plugins/utils.js +5 -6
- package/dist/es2019/services/use-search-query/index.js +3 -6
- package/dist/es2019/ui/error-boundary/error-boundary-base/index.js +0 -5
- package/dist/es2019/ui/error-boundary/index.js +2 -4
- package/dist/es2019/ui/index.js +1 -2
- package/dist/es2019/ui/link-picker/announcer.js +6 -1
- package/dist/es2019/ui/link-picker/browser.js +0 -2
- package/dist/es2019/ui/link-picker/form-footer/index.js +0 -5
- package/dist/es2019/ui/link-picker/form-footer/utils.js +2 -5
- package/dist/es2019/ui/link-picker/index.js +21 -37
- package/dist/es2019/ui/link-picker/link-search-error/index.js +0 -3
- package/dist/es2019/ui/link-picker/link-search-list/index.js +2 -6
- package/dist/es2019/ui/link-picker/link-search-list/link-search-no-results/index.js +0 -2
- package/dist/es2019/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/index.js +0 -3
- package/dist/es2019/ui/link-picker/link-search-list/styled.js +2 -2
- package/dist/es2019/ui/link-picker/link-search-list/use-track-results-shown/index.js +7 -5
- package/dist/es2019/ui/link-picker/list-item/index.js +0 -14
- package/dist/es2019/ui/link-picker/list-item/styled.js +2 -4
- package/dist/es2019/ui/link-picker/styled.js +1 -1
- package/dist/es2019/ui/link-picker/text-input/index.js +0 -6
- package/dist/es2019/ui/link-picker/track-mount/index.js +1 -2
- package/dist/es2019/ui/link-picker/track-tab-viewed/index.js +0 -2
- package/dist/es2019/ui/link-picker/transformTimeStamp.js +0 -7
- package/dist/es2019/ui/link-picker/utils.js +7 -5
- package/dist/es2019/ui/scrolling-tabs/index.js +2 -14
- package/dist/es2019/ui/scrolling-tabs/scrolling-tabs.js +0 -14
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics.codegen.js +1 -1
- package/dist/esm/common/analytics/context.js +11 -21
- package/dist/esm/common/analytics/experiences.js +0 -3
- package/dist/esm/common/analytics/input-field-tracking.js +16 -22
- package/dist/esm/common/generic-error-svg/index.js +0 -4
- package/dist/esm/common/generic-error-svg/styled.js +0 -2
- package/dist/esm/common/utils/errors.js +0 -8
- package/dist/esm/controllers/session-provider/index.js +1 -7
- package/dist/esm/controllers/use-fix-height/index.js +0 -2
- package/dist/esm/services/use-plugins/index.js +13 -31
- package/dist/esm/services/use-plugins/reducer.js +0 -7
- package/dist/esm/services/use-plugins/utils.js +9 -22
- package/dist/esm/services/use-search-query/index.js +3 -6
- package/dist/esm/ui/error-boundary/error-boundary-base/index.js +2 -13
- package/dist/esm/ui/error-boundary/index.js +3 -5
- package/dist/esm/ui/index.js +1 -2
- package/dist/esm/ui/link-picker/announcer.js +20 -17
- package/dist/esm/ui/link-picker/browser.js +0 -2
- package/dist/esm/ui/link-picker/form-footer/index.js +6 -12
- package/dist/esm/ui/link-picker/form-footer/styled.js +0 -2
- package/dist/esm/ui/link-picker/form-footer/utils.js +2 -5
- package/dist/esm/ui/link-picker/index.js +44 -74
- package/dist/esm/ui/link-picker/link-search-error/index.js +0 -3
- package/dist/esm/ui/link-picker/link-search-list/index.js +12 -20
- package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/index.js +0 -2
- package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/index.js +0 -3
- package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/styled.js +0 -2
- package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/styled.js +0 -2
- package/dist/esm/ui/link-picker/link-search-list/styled.js +2 -4
- package/dist/esm/ui/link-picker/link-search-list/use-track-results-shown/index.js +11 -11
- package/dist/esm/ui/link-picker/list-item/index.js +10 -25
- package/dist/esm/ui/link-picker/list-item/styled.js +2 -6
- package/dist/esm/ui/link-picker/styled.js +1 -3
- package/dist/esm/ui/link-picker/text-input/index.js +9 -16
- package/dist/esm/ui/link-picker/text-input/styled.js +0 -2
- package/dist/esm/ui/link-picker/track-mount/index.js +2 -4
- package/dist/esm/ui/link-picker/track-tab-viewed/index.js +1 -5
- package/dist/esm/ui/link-picker/transformTimeStamp.js +0 -7
- package/dist/esm/ui/link-picker/utils.js +11 -9
- package/dist/esm/ui/scrolling-tabs/index.js +6 -28
- package/dist/esm/ui/scrolling-tabs/scrolling-tabs.js +4 -19
- package/dist/esm/version.json +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { jsx } from '@emotion/react';
|
|
5
4
|
import { useIntl, FormattedMessage, defineMessages } from 'react-intl-next';
|
|
@@ -22,7 +21,6 @@ export const messages = defineMessages({
|
|
|
22
21
|
export const testIds = {
|
|
23
22
|
searchError: 'link-search-error'
|
|
24
23
|
};
|
|
25
|
-
|
|
26
24
|
const LinkSearchError = () => {
|
|
27
25
|
const intl = useIntl();
|
|
28
26
|
return jsx(EmptyState, {
|
|
@@ -42,5 +40,4 @@ const LinkSearchError = () => {
|
|
|
42
40
|
renderImage: () => jsx(GenericErrorSVG, null)
|
|
43
41
|
});
|
|
44
42
|
};
|
|
45
|
-
|
|
46
43
|
export default LinkSearchError;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { forwardRef, Fragment } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
@@ -27,7 +26,8 @@ export const messages = defineMessages({
|
|
|
27
26
|
description: 'Announce search results for screen-reader users.'
|
|
28
27
|
}
|
|
29
28
|
});
|
|
30
|
-
export const testIds = {
|
|
29
|
+
export const testIds = {
|
|
30
|
+
...noResultsTestIds,
|
|
31
31
|
resultListTitle: 'link-picker-list-title',
|
|
32
32
|
searchResultItem: 'link-search-list-item',
|
|
33
33
|
searchResultList: 'link-search-list',
|
|
@@ -52,11 +52,9 @@ const LinkSearchList = /*#__PURE__*/forwardRef(({
|
|
|
52
52
|
let loadingContent;
|
|
53
53
|
const linkListTitle = hasSearchTerm ? messages.titleResults : messages.titleRecentlyViewed;
|
|
54
54
|
useTrackResultsShown(isLoading, items, hasSearchTerm);
|
|
55
|
-
|
|
56
55
|
if ((items === null || items === void 0 ? void 0 : items.length) === 0) {
|
|
57
56
|
return jsx(LinkSearchNoResults, null);
|
|
58
57
|
}
|
|
59
|
-
|
|
60
58
|
if (items && items.length > 0) {
|
|
61
59
|
itemsContent = jsx(Fragment, null, jsx("div", {
|
|
62
60
|
css: listTitleStyles,
|
|
@@ -89,7 +87,6 @@ const LinkSearchList = /*#__PURE__*/forwardRef(({
|
|
|
89
87
|
key: item.objectId
|
|
90
88
|
}))));
|
|
91
89
|
}
|
|
92
|
-
|
|
93
90
|
if (isLoading) {
|
|
94
91
|
loadingContent = jsx("div", {
|
|
95
92
|
css: spinnerContainerStyles
|
|
@@ -98,7 +95,6 @@ const LinkSearchList = /*#__PURE__*/forwardRef(({
|
|
|
98
95
|
size: "medium"
|
|
99
96
|
}));
|
|
100
97
|
}
|
|
101
|
-
|
|
102
98
|
return jsx("div", _extends({
|
|
103
99
|
ref: ref,
|
|
104
100
|
css: listContainerStyles
|
|
@@ -19,7 +19,6 @@ export const messages = defineMessages({
|
|
|
19
19
|
export const testIds = {
|
|
20
20
|
emptyResultPage: 'link-search-no-results'
|
|
21
21
|
};
|
|
22
|
-
|
|
23
22
|
const NoResults = () => {
|
|
24
23
|
const intl = useIntl();
|
|
25
24
|
return jsx("div", {
|
|
@@ -31,5 +30,4 @@ const NoResults = () => {
|
|
|
31
30
|
renderImage: () => jsx(NoResultsSVG, null)
|
|
32
31
|
}));
|
|
33
32
|
};
|
|
34
|
-
|
|
35
33
|
export default NoResults;
|
package/dist/es2019/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { jsx } from '@emotion/react';
|
|
5
4
|
import { noResultsSVGStyles } from './styled';
|
|
6
|
-
|
|
7
5
|
const NoResultsSVG = () => {
|
|
8
6
|
const id = 'link-picker-ui-no-results-svg';
|
|
9
7
|
return jsx("svg", {
|
|
@@ -56,5 +54,4 @@ const NoResultsSVG = () => {
|
|
|
56
54
|
d: "M0 0h207.16v189.87H0z"
|
|
57
55
|
}))));
|
|
58
56
|
};
|
|
59
|
-
|
|
60
57
|
export default NoResultsSVG;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
// AFP-2532 TODO: Fix automatic suppressions below
|
|
2
3
|
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
3
|
-
|
|
4
4
|
import { typography } from '@atlaskit/theme';
|
|
5
5
|
import { gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
6
6
|
const gridSize = getGridSize();
|
|
@@ -8,20 +8,22 @@ export const useTrackResultsShown = (isLoading, items, hasSearchTerm) => {
|
|
|
8
8
|
const {
|
|
9
9
|
createAnalyticsEvent
|
|
10
10
|
} = useAnalyticsEvents();
|
|
11
|
-
const hasSearchTermRef = useRef(hasSearchTerm);
|
|
11
|
+
const hasSearchTermRef = useRef(hasSearchTerm);
|
|
12
|
+
// Using ref so that not required in the dependency array
|
|
12
13
|
// Analytics should be entirely dependent on change of items being viewed
|
|
13
|
-
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
hasSearchTermRef.current = hasSearchTerm;
|
|
16
|
-
}, [hasSearchTerm]);
|
|
16
|
+
}, [hasSearchTerm]);
|
|
17
|
+
|
|
18
|
+
// Filters isLoading/items to only return the array of items if no longer loading more items
|
|
17
19
|
// Loading state IS a factor here because some tabs will
|
|
18
20
|
// load intermediate results whilst loading additional results (Atlassian tab)
|
|
19
21
|
// Considered to only have "shown" results once we are in a final state (no longer loading)
|
|
22
|
+
const finalItems = useMemo(() => !isLoading ? items : null, [isLoading, items]);
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
// Because Atlassian tab resolves intermediate results on every keystroke (may never be loading)
|
|
22
25
|
// Debounce the items so that we only consider the results to have been shown
|
|
23
26
|
// after they have been stable for DEBOUNCE_MS
|
|
24
|
-
|
|
25
27
|
const [debouncedItems] = useDebounce(finalItems, DEBOUNCE_MS);
|
|
26
28
|
useEffect(() => {
|
|
27
29
|
if (debouncedItems) {
|
|
@@ -5,7 +5,6 @@ import { injectIntl } from 'react-intl-next';
|
|
|
5
5
|
import { transformTimeStamp } from '../transformTimeStamp';
|
|
6
6
|
import { itemNameStyles, itemIconStyles, listItemContextStyles, listItemNameStyles, composeListItemStyles, imgStyles, listItemContainerStyles, listItemContainerInnerStyles } from './styled';
|
|
7
7
|
import { testIds } from '..';
|
|
8
|
-
|
|
9
8
|
const LinkSearchListItem = ({
|
|
10
9
|
item,
|
|
11
10
|
selected,
|
|
@@ -18,11 +17,8 @@ const LinkSearchListItem = ({
|
|
|
18
17
|
onMouseLeave
|
|
19
18
|
}) => {
|
|
20
19
|
const handleSelect = () => onSelect(item.objectId);
|
|
21
|
-
|
|
22
20
|
const handleMouseEnter = () => onMouseEnter(item.objectId);
|
|
23
|
-
|
|
24
21
|
const handleMouseLeave = () => onMouseLeave(item.objectId);
|
|
25
|
-
|
|
26
22
|
const container = item.container || null;
|
|
27
23
|
const date = transformTimeStamp(intl, item.lastViewedDate, item.lastUpdatedDate);
|
|
28
24
|
return jsx("div", {
|
|
@@ -53,19 +49,13 @@ const LinkSearchListItem = ({
|
|
|
53
49
|
css: listItemContainerInnerStyles
|
|
54
50
|
}, container && jsx(Fragment, null, "\xA0 \u2022\xA0 "), jsx(Fragment, null, formatDate(date))))));
|
|
55
51
|
};
|
|
56
|
-
|
|
57
52
|
export default injectIntl(LinkSearchListItem);
|
|
58
|
-
|
|
59
53
|
const formatDate = date => {
|
|
60
54
|
return [date.pageAction, date.dateString, date.timeSince].filter(Boolean).join(' ');
|
|
61
55
|
};
|
|
62
|
-
|
|
63
56
|
const isSVG = icon => icon.startsWith('<svg') && icon.endsWith('</svg>');
|
|
64
|
-
|
|
65
57
|
const base64SVG = icon => `data:image/svg+xml;base64,${Buffer.from(icon).toString('base64')}`;
|
|
66
|
-
|
|
67
58
|
const testId = 'link-search-list-item-icon';
|
|
68
|
-
|
|
69
59
|
const ListItemIcon = props => {
|
|
70
60
|
const {
|
|
71
61
|
item,
|
|
@@ -75,13 +65,10 @@ const ListItemIcon = props => {
|
|
|
75
65
|
icon,
|
|
76
66
|
iconAlt
|
|
77
67
|
} = item;
|
|
78
|
-
|
|
79
68
|
if (!icon) {
|
|
80
69
|
return null;
|
|
81
70
|
}
|
|
82
|
-
|
|
83
71
|
const alt = typeof iconAlt === 'string' ? iconAlt : intl.formatMessage(iconAlt);
|
|
84
|
-
|
|
85
72
|
if (typeof icon !== 'string') {
|
|
86
73
|
const Glyph = icon;
|
|
87
74
|
return jsx("span", {
|
|
@@ -91,7 +78,6 @@ const ListItemIcon = props => {
|
|
|
91
78
|
"data-testid": testId
|
|
92
79
|
}));
|
|
93
80
|
}
|
|
94
|
-
|
|
95
81
|
return jsx("span", {
|
|
96
82
|
css: itemIconStyles
|
|
97
83
|
}, jsx("img", {
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { B50, N300, N800, N20, B400 } from '@atlaskit/theme/colors';
|
|
3
|
-
import { gridSize } from '@atlaskit/theme/constants';
|
|
3
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
4
|
+
// AFP-2532 TODO: Fix automatic suppressions below
|
|
4
5
|
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
|
-
|
|
6
6
|
import { fontSizeSmall, fontSize } from '@atlaskit/theme';
|
|
7
7
|
export const relativeFontSizeToBase16 = px => {
|
|
8
8
|
if (typeof px === 'string') {
|
|
9
9
|
px = parseInt(px);
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
if (isNaN(px)) {
|
|
13
12
|
throw new Error(`Invalid font size: '${px}'`);
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
return `${px / 16}rem`;
|
|
17
15
|
};
|
|
18
16
|
const listItemBaseStyles = css`
|
|
@@ -4,10 +4,10 @@ import { gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
|
4
4
|
const LINK_PICKER_WIDTH_IN_PX = 342;
|
|
5
5
|
const LINK_PICKER_MIN_HEIGHT_IN_PX = 220;
|
|
6
6
|
const gridSize = getGridSize();
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Half padding on the top as the form field has a `gridSize()` margin top that cannot be overridden
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
11
|
export const rootContainerStyles = css`
|
|
12
12
|
width: ${LINK_PICKER_WIDTH_IN_PX}px;
|
|
13
13
|
padding: ${gridSize}px ${gridSize * 2}px ${gridSize * 2}px;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { useCallback, useRef, Fragment } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
@@ -13,7 +12,6 @@ export const testIds = {
|
|
|
13
12
|
urlError: 'link-error',
|
|
14
13
|
clearUrlButton: 'clear-text'
|
|
15
14
|
};
|
|
16
|
-
|
|
17
15
|
const TextInput = ({
|
|
18
16
|
name,
|
|
19
17
|
label,
|
|
@@ -30,7 +28,6 @@ const TextInput = ({
|
|
|
30
28
|
const handleRef = useCallback(input => {
|
|
31
29
|
if (input) {
|
|
32
30
|
inputRef.current = input;
|
|
33
|
-
|
|
34
31
|
if (autoFocus) {
|
|
35
32
|
// Need this to prevent jumping when we render TextInput inside Portal @see ED-2992
|
|
36
33
|
input.focus({
|
|
@@ -47,14 +44,12 @@ const TextInput = ({
|
|
|
47
44
|
e.preventDefault();
|
|
48
45
|
onRedo();
|
|
49
46
|
}
|
|
50
|
-
|
|
51
47
|
if (onKeyDown) {
|
|
52
48
|
onKeyDown(e);
|
|
53
49
|
}
|
|
54
50
|
}, [onUndo, onRedo, onKeyDown]);
|
|
55
51
|
const handleClear = useCallback(e => {
|
|
56
52
|
var _inputRef$current;
|
|
57
|
-
|
|
58
53
|
e.preventDefault();
|
|
59
54
|
e.stopPropagation();
|
|
60
55
|
onClear === null || onClear === void 0 ? void 0 : onClear(name);
|
|
@@ -89,5 +84,4 @@ const TextInput = ({
|
|
|
89
84
|
}, error));
|
|
90
85
|
}));
|
|
91
86
|
};
|
|
92
|
-
|
|
93
87
|
export default TextInput;
|
|
@@ -5,10 +5,10 @@ import { succeedUfoExperience, ufoExperience } from '../../../common/analytics/e
|
|
|
5
5
|
import createEventPayload from '../../../analytics.codegen';
|
|
6
6
|
import { ANALYTICS_CHANNEL } from '../../../common/constants';
|
|
7
7
|
import { useLinkPickerSessionId } from '../../../controllers/session-provider';
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* UFO + Analytics tracking for component mount (and unmount)
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
12
|
function TrackMount() {
|
|
13
13
|
const {
|
|
14
14
|
createAnalyticsEvent
|
|
@@ -27,5 +27,4 @@ function TrackMount() {
|
|
|
27
27
|
}, [createAnalyticsEvent]);
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
export default TrackMount;
|
|
@@ -3,7 +3,6 @@ import { useLayoutEffect } from 'react';
|
|
|
3
3
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
4
4
|
import createEventPayload from '../../../analytics.codegen';
|
|
5
5
|
import { ANALYTICS_CHANNEL } from '../../../common/constants';
|
|
6
|
-
|
|
7
6
|
function TrackTabViewed({
|
|
8
7
|
activeTab
|
|
9
8
|
}) {
|
|
@@ -15,5 +14,4 @@ function TrackTabViewed({
|
|
|
15
14
|
}, [activeTab, createAnalyticsEvent]);
|
|
16
15
|
return null;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
export default TrackTabViewed;
|
|
@@ -2,39 +2,32 @@ import formatDistance from 'date-fns/formatDistance';
|
|
|
2
2
|
import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
|
|
3
3
|
import format from 'date-fns/format';
|
|
4
4
|
import { messages } from './messages';
|
|
5
|
-
|
|
6
5
|
const renderAbsoluteOrRelativeDate = (timeStamp, pageAction, intl) => {
|
|
7
6
|
let pageActionText = '';
|
|
8
|
-
|
|
9
7
|
switch (pageAction) {
|
|
10
8
|
case 'updated':
|
|
11
9
|
pageActionText = intl.formatMessage(messages.timeUpdated);
|
|
12
10
|
break;
|
|
13
|
-
|
|
14
11
|
case 'viewed':
|
|
15
12
|
pageActionText = intl.formatMessage(messages.timeViewed);
|
|
16
13
|
break;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
if (differenceInCalendarDays(timeStamp, Date.now()) < -7) {
|
|
20
16
|
return {
|
|
21
17
|
pageAction: pageActionText,
|
|
22
18
|
dateString: format(timeStamp, 'MMMM dd, yyyy')
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
return {
|
|
27
22
|
pageAction: pageActionText,
|
|
28
23
|
dateString: formatDistance(timeStamp, Date.now()),
|
|
29
24
|
timeSince: intl.formatMessage(messages.timeAgo)
|
|
30
25
|
};
|
|
31
26
|
};
|
|
32
|
-
|
|
33
27
|
export const transformTimeStamp = (intl, lastViewedDate, lastUpdatedDate) => {
|
|
34
28
|
if (lastViewedDate) {
|
|
35
29
|
return renderAbsoluteOrRelativeDate(lastViewedDate, 'viewed', intl);
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
if (lastUpdatedDate) {
|
|
39
32
|
return renderAbsoluteOrRelativeDate(lastUpdatedDate, 'updated', intl);
|
|
40
33
|
}
|
|
@@ -3,22 +3,24 @@ import { transformTimeStamp } from './transformTimeStamp';
|
|
|
3
3
|
const KeyZCode = 90;
|
|
4
4
|
const KeyYCode = 89;
|
|
5
5
|
export const isUndoEvent = e => {
|
|
6
|
-
return e.keyCode === KeyZCode && (
|
|
7
|
-
|
|
6
|
+
return e.keyCode === KeyZCode && (
|
|
7
|
+
// cmd + z for mac
|
|
8
|
+
browser.mac && e.metaKey && !e.shiftKey ||
|
|
9
|
+
// ctrl + z for non-mac
|
|
8
10
|
!browser.mac && e.ctrlKey);
|
|
9
11
|
};
|
|
10
12
|
export const isRedoEvent = e => {
|
|
11
|
-
return (
|
|
13
|
+
return (
|
|
14
|
+
// ctrl + y for non-mac
|
|
12
15
|
!browser.mac && e.ctrlKey && e.keyCode === KeyYCode || browser.mac && e.metaKey && e.shiftKey && e.keyCode === KeyZCode || e.ctrlKey && e.shiftKey && e.keyCode === KeyZCode
|
|
13
16
|
);
|
|
14
17
|
};
|
|
18
|
+
|
|
15
19
|
/**
|
|
16
20
|
* Retrieve the data source for a link given the item and the plugin that resolved it
|
|
17
21
|
*/
|
|
18
|
-
|
|
19
22
|
export const getDataSource = (item, plugin) => {
|
|
20
23
|
var _ref, _item$meta$source, _item$meta, _plugin$meta;
|
|
21
|
-
|
|
22
24
|
return (_ref = (_item$meta$source = (_item$meta = item.meta) === null || _item$meta === void 0 ? void 0 : _item$meta.source) !== null && _item$meta$source !== void 0 ? _item$meta$source : plugin === null || plugin === void 0 ? void 0 : (_plugin$meta = plugin.meta) === null || _plugin$meta === void 0 ? void 0 : _plugin$meta.source) !== null && _ref !== void 0 ? _ref : 'unknown';
|
|
23
25
|
};
|
|
24
26
|
export function getScreenReaderText(items, selectedIndex, intl) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import React, { useRef, useMemo, useState, useCallback } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
@@ -8,12 +7,11 @@ import ChevronLeftIcon from '@atlaskit/icon/glyph/chevron-left';
|
|
|
8
7
|
import ChevronRightIcon from '@atlaskit/icon/glyph/chevron-right';
|
|
9
8
|
import { scrollBack, scrollForward, calculateConditionalButtons, getTabList, createGhost } from './scrolling-tabs';
|
|
10
9
|
import { containerStyles, scrollingContainerStyles, nextButtonStyles, backButtonStyles } from './styles';
|
|
11
|
-
|
|
12
10
|
function isTouchDevice() {
|
|
13
|
-
return 'ontouchstart' in window ||
|
|
11
|
+
return 'ontouchstart' in window ||
|
|
12
|
+
// eslint-disable-next-line compat/compat
|
|
14
13
|
navigator.maxTouchPoints > 0;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
const initialConditionalButtonsState = {
|
|
18
16
|
back: false,
|
|
19
17
|
forward: false
|
|
@@ -24,7 +22,6 @@ export const ScrollingTabList = props => {
|
|
|
24
22
|
const ghost = useMemo(() => createGhost(), []);
|
|
25
23
|
const onTabClick = useCallback(e => {
|
|
26
24
|
const target = e.currentTarget;
|
|
27
|
-
|
|
28
25
|
if (target) {
|
|
29
26
|
target.scrollIntoView({
|
|
30
27
|
behavior: 'smooth',
|
|
@@ -37,20 +34,16 @@ export const ScrollingTabList = props => {
|
|
|
37
34
|
const container = ref.current;
|
|
38
35
|
let scrollingContainer;
|
|
39
36
|
let tabs;
|
|
40
|
-
|
|
41
37
|
const handleConditionalButtonsChange = () => {
|
|
42
38
|
const buttons = calculateConditionalButtons(scrollingContainer, isTouchDevice());
|
|
43
39
|
setConditionalButtons(buttons);
|
|
44
40
|
};
|
|
45
|
-
|
|
46
41
|
const observerCallback = mutationList => {
|
|
47
42
|
const tablist = getTabList(ref);
|
|
48
|
-
|
|
49
43
|
for (const mutation of mutationList) {
|
|
50
44
|
if (mutation.type === 'childList') {
|
|
51
45
|
const addedNodes = Array.from(mutation.addedNodes);
|
|
52
46
|
const found = addedNodes.find(node => node.getAttribute('role') === 'tab');
|
|
53
|
-
|
|
54
47
|
if (found && tablist) {
|
|
55
48
|
ghost.remove();
|
|
56
49
|
const tabs = Array.from(tablist.children);
|
|
@@ -64,9 +57,7 @@ export const ScrollingTabList = props => {
|
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
59
|
};
|
|
67
|
-
|
|
68
60
|
const observer = new MutationObserver(observerCallback);
|
|
69
|
-
|
|
70
61
|
if (container) {
|
|
71
62
|
const tablist = getTabList(ref);
|
|
72
63
|
scrollingContainer = tablist === null || tablist === void 0 ? void 0 : tablist.parentElement;
|
|
@@ -75,7 +66,6 @@ export const ScrollingTabList = props => {
|
|
|
75
66
|
childList: true,
|
|
76
67
|
subtree: true
|
|
77
68
|
});
|
|
78
|
-
|
|
79
69
|
if (scrollingContainer instanceof HTMLElement && tablist) {
|
|
80
70
|
tablist.appendChild(ghost);
|
|
81
71
|
tabs = Array.from(tablist.children);
|
|
@@ -83,12 +73,10 @@ export const ScrollingTabList = props => {
|
|
|
83
73
|
handleConditionalButtonsChange();
|
|
84
74
|
scrollingContainer.addEventListener('scroll', handleConditionalButtonsChange);
|
|
85
75
|
}
|
|
86
|
-
|
|
87
76
|
return () => {
|
|
88
77
|
if (scrollingContainer) {
|
|
89
78
|
scrollingContainer.removeEventListener('scroll', handleConditionalButtonsChange);
|
|
90
79
|
}
|
|
91
|
-
|
|
92
80
|
if (tabs.length) {
|
|
93
81
|
tabs.forEach(tab => tab.removeEventListener('click', onTabClick));
|
|
94
82
|
}
|
|
@@ -12,11 +12,9 @@ export const calculateConditionalButtons = (container, hideButtons) => {
|
|
|
12
12
|
back: false,
|
|
13
13
|
forward: false
|
|
14
14
|
};
|
|
15
|
-
|
|
16
15
|
if (!container || hideButtons) {
|
|
17
16
|
return initialState;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
const maxScrollValue = container.scrollWidth - container.clientWidth;
|
|
21
19
|
return {
|
|
22
20
|
back: container.scrollLeft > 0,
|
|
@@ -30,17 +28,13 @@ export const createGhost = () => {
|
|
|
30
28
|
ghost.style.pointerEvents = 'none';
|
|
31
29
|
return ghost;
|
|
32
30
|
};
|
|
33
|
-
|
|
34
31
|
const moveTabsScroll = (ref, findFn) => {
|
|
35
32
|
const container = getContainer(ref);
|
|
36
|
-
|
|
37
33
|
if (container) {
|
|
38
34
|
const tablist = container.children[0];
|
|
39
35
|
const tabs = [...tablist.children];
|
|
40
|
-
|
|
41
36
|
if (tabs.length > 0) {
|
|
42
37
|
const target = findFn(container, tabs);
|
|
43
|
-
|
|
44
38
|
if (target) {
|
|
45
39
|
const left = container.scrollLeft + target.getBoundingClientRect().left - container.getBoundingClientRect().left - BUTTON_SIZE;
|
|
46
40
|
scrollTo(container, left);
|
|
@@ -48,38 +42,30 @@ const moveTabsScroll = (ref, findFn) => {
|
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
44
|
};
|
|
51
|
-
|
|
52
45
|
const scrollTo = (container, left) => {
|
|
53
46
|
container.scrollTo({
|
|
54
47
|
left
|
|
55
48
|
});
|
|
56
49
|
};
|
|
57
|
-
|
|
58
50
|
export const getTabList = ref => {
|
|
59
51
|
var _ref$current;
|
|
60
|
-
|
|
61
52
|
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('[role="tablist"]');
|
|
62
53
|
};
|
|
63
54
|
export const getContainer = ref => {
|
|
64
55
|
var _getTabList;
|
|
65
|
-
|
|
66
56
|
return (_getTabList = getTabList(ref)) === null || _getTabList === void 0 ? void 0 : _getTabList.parentElement;
|
|
67
57
|
};
|
|
68
|
-
|
|
69
58
|
const findPrevious = (container, tabs) => {
|
|
70
59
|
const previousTabs = tabs.filter(tab => {
|
|
71
60
|
const [containerRect, tabRect] = [container.getBoundingClientRect(), tab.getBoundingClientRect()];
|
|
72
61
|
const [containerArea, tabArea] = [containerRect.left + container.scrollLeft - GUTTER, container.scrollLeft + tabRect.left + tabRect.width];
|
|
73
62
|
return containerArea > tabArea;
|
|
74
63
|
});
|
|
75
|
-
|
|
76
64
|
if (previousTabs.length < 3) {
|
|
77
65
|
return previousTabs[0];
|
|
78
66
|
}
|
|
79
|
-
|
|
80
67
|
return previousTabs[previousTabs.length - 1];
|
|
81
68
|
};
|
|
82
|
-
|
|
83
69
|
const findNext = (container, tabs) => {
|
|
84
70
|
const containerRect = container.getBoundingClientRect();
|
|
85
71
|
return tabs.find(tab => {
|
package/dist/es2019/version.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @codegen <<SignedSource::254da005ee62004d45537995770eba56>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
8
8
|
*/
|
|
9
|
+
|
|
9
10
|
function createEventPayload(eventKey, attributes) {
|
|
10
11
|
var event = eventKey.split('.');
|
|
11
12
|
return {
|
|
@@ -16,5 +17,4 @@ function createEventPayload(eventKey, attributes) {
|
|
|
16
17
|
attributes: attributes
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
|
|
20
20
|
export default createEventPayload;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
|
|
5
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; }
|
|
6
|
-
|
|
7
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; }
|
|
8
|
-
|
|
9
6
|
import React, { useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
10
7
|
import { AnalyticsListener } from '@atlaskit/analytics-next';
|
|
11
8
|
import { ANALYTICS_CHANNEL } from '../constants';
|
|
@@ -26,14 +23,13 @@ var LinkPickerAnalyticsContext = /*#__PURE__*/React.createContext({
|
|
|
26
23
|
return DEFAULT_CONTEXT_ATTRIBUTES;
|
|
27
24
|
}
|
|
28
25
|
});
|
|
26
|
+
|
|
29
27
|
/**
|
|
30
28
|
* TODO: Should we hook this into the form state/reducer?
|
|
31
29
|
* This function continues to duplicate / assume logic that runs in the picker
|
|
32
30
|
*/
|
|
33
|
-
|
|
34
31
|
var contextAttributesFromIntialProps = function contextAttributesFromIntialProps(props) {
|
|
35
32
|
var _props$plugins$0$tabK, _props$plugins, _props$plugins$;
|
|
36
|
-
|
|
37
33
|
return {
|
|
38
34
|
linkState: normalizeUrl(props.url) ? 'editLink' : 'newLink',
|
|
39
35
|
linkFieldContent: normalizeUrl(props.url) ? 'url' : null,
|
|
@@ -42,14 +38,13 @@ var contextAttributesFromIntialProps = function contextAttributesFromIntialProps
|
|
|
42
38
|
tab: (_props$plugins$0$tabK = (_props$plugins = props.plugins) === null || _props$plugins === void 0 ? void 0 : (_props$plugins$ = _props$plugins[0]) === null || _props$plugins$ === void 0 ? void 0 : _props$plugins$.tabKey) !== null && _props$plugins$0$tabK !== void 0 ? _props$plugins$0$tabK : null
|
|
43
39
|
};
|
|
44
40
|
};
|
|
41
|
+
|
|
45
42
|
/**
|
|
46
43
|
* Context for tracking attributes to deliver at a context-level
|
|
47
44
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
45
|
var LinkPickerAnalytics = function LinkPickerAnalytics(_ref) {
|
|
51
46
|
var initialContext = _ref.initialContext,
|
|
52
|
-
|
|
47
|
+
children = _ref.children;
|
|
53
48
|
var dataRef = useRef(_objectSpread(_objectSpread({}, DEFAULT_CONTEXT_ATTRIBUTES), initialContext));
|
|
54
49
|
var methods = useMemo(function () {
|
|
55
50
|
return {
|
|
@@ -68,45 +63,40 @@ var LinkPickerAnalytics = function LinkPickerAnalytics(_ref) {
|
|
|
68
63
|
value: methods
|
|
69
64
|
}, children);
|
|
70
65
|
};
|
|
66
|
+
|
|
71
67
|
/**
|
|
72
68
|
* Hook that exposes the context-level attribute getters and setters.
|
|
73
69
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
70
|
export var useLinkPickerAnalytics = function useLinkPickerAnalytics() {
|
|
77
71
|
return useContext(LinkPickerAnalyticsContext);
|
|
78
72
|
};
|
|
73
|
+
|
|
79
74
|
/**
|
|
80
75
|
* Wrap component in "attributes" context store and initialise the initial context attributes from props.
|
|
81
76
|
*/
|
|
82
|
-
|
|
83
77
|
function withLinkPickerAnalytics(WrappedComponent) {
|
|
84
78
|
return function (props) {
|
|
85
79
|
var _useState = useState(function () {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
return contextAttributesFromIntialProps(props);
|
|
81
|
+
}),
|
|
82
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
83
|
+
initialContext = _useState2[0];
|
|
91
84
|
return /*#__PURE__*/React.createElement(LinkPickerAnalytics, _extends({
|
|
92
85
|
initialContext: initialContext
|
|
93
86
|
}, props), /*#__PURE__*/React.createElement(WrappedComponent, props));
|
|
94
87
|
};
|
|
95
88
|
}
|
|
89
|
+
|
|
96
90
|
/**
|
|
97
91
|
* Wraps a component with the analytics context + listener to update events with contextual-level attributes.
|
|
98
92
|
* Should be implemented once at the root of the link picker.
|
|
99
93
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
94
|
export function withLinkPickerAnalyticsContext(WrappedComponent) {
|
|
103
95
|
return withLinkPickerAnalytics(function (props) {
|
|
104
96
|
var _useLinkPickerAnalyti = useLinkPickerAnalytics(),
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
getAttributes = _useLinkPickerAnalyti.getAttributes;
|
|
107
98
|
var onEvent = useCallback(function (event) {
|
|
108
99
|
var _event$payload$attrib;
|
|
109
|
-
|
|
110
100
|
event.update({
|
|
111
101
|
attributes: _objectSpread(_objectSpread({}, getAttributes()), (_event$payload$attrib = event.payload.attributes) !== null && _event$payload$attrib !== void 0 ? _event$payload$attrib : {})
|
|
112
102
|
});
|
|
@@ -3,7 +3,6 @@ import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } fro
|
|
|
3
3
|
export var ufoExperience = {
|
|
4
4
|
mounted: 'component-mounted'
|
|
5
5
|
};
|
|
6
|
-
|
|
7
6
|
var ufoExperiences = _defineProperty({}, ufoExperience.mounted, new ConcurrentExperience(ufoExperience.mounted, {
|
|
8
7
|
type: ExperienceTypes.Load,
|
|
9
8
|
performanceType: ExperiencePerformanceTypes.PageSegmentLoad,
|
|
@@ -11,11 +10,9 @@ var ufoExperiences = _defineProperty({}, ufoExperience.mounted, new ConcurrentEx
|
|
|
11
10
|
component: 'link-picker'
|
|
12
11
|
}
|
|
13
12
|
}));
|
|
14
|
-
|
|
15
13
|
export var startUfoExperience = function startUfoExperience(experienceName, id, metadata) {
|
|
16
14
|
var experience = ufoExperiences[experienceName].getInstance(id);
|
|
17
15
|
experience.start();
|
|
18
|
-
|
|
19
16
|
if (metadata) {
|
|
20
17
|
experience.addMetadata(metadata);
|
|
21
18
|
}
|