@atlaskit/link-picker 1.42.5 → 1.44.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 +24 -0
- package/dist/cjs/ui/link-picker/form-footer/index.js +15 -26
- package/dist/cjs/ui/link-picker/form-footer/link-picker-submit-button/index.js +52 -0
- package/dist/cjs/ui/link-picker/index.js +32 -3
- package/dist/cjs/ui/link-picker/search-results/link-search-list/index.js +16 -14
- package/dist/cjs/ui/link-picker/search-results/link-search-list/list-item/index.js +54 -30
- package/dist/cjs/ui/link-picker/search-results/link-search-list/list-item/styled.js +3 -11
- package/dist/cjs/ui/main.js +1 -1
- package/dist/es2019/ui/link-picker/form-footer/index.js +15 -24
- package/dist/es2019/ui/link-picker/form-footer/link-picker-submit-button/index.js +45 -0
- package/dist/es2019/ui/link-picker/index.js +30 -4
- package/dist/es2019/ui/link-picker/search-results/link-search-list/index.js +17 -15
- package/dist/es2019/ui/link-picker/search-results/link-search-list/list-item/index.js +43 -23
- package/dist/es2019/ui/link-picker/search-results/link-search-list/list-item/styled.js +3 -11
- package/dist/es2019/ui/main.js +1 -1
- package/dist/esm/ui/link-picker/form-footer/index.js +16 -27
- package/dist/esm/ui/link-picker/form-footer/link-picker-submit-button/index.js +44 -0
- package/dist/esm/ui/link-picker/index.js +33 -4
- package/dist/esm/ui/link-picker/search-results/link-search-list/index.js +17 -15
- package/dist/esm/ui/link-picker/search-results/link-search-list/list-item/index.js +54 -31
- package/dist/esm/ui/link-picker/search-results/link-search-list/list-item/styled.js +3 -11
- package/dist/esm/ui/main.js +1 -1
- package/dist/types/common/types.d.ts +17 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/ui/link-picker/form-footer/index.d.ts +3 -11
- package/dist/types/ui/link-picker/form-footer/link-picker-submit-button/index.d.ts +33 -0
- package/dist/{types-ts4.5/ui/link-picker/form-footer → types/ui/link-picker/form-footer/link-picker-submit-button}/utils.d.ts +1 -1
- package/dist/types/ui/link-picker/search-results/link-search-list/list-item/index.d.ts +1 -0
- package/dist/types/ui/link-picker/search-results/link-search-list/list-item/styled.d.ts +0 -1
- package/dist/types-ts4.5/common/types.d.ts +20 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/link-picker/form-footer/index.d.ts +3 -11
- package/dist/types-ts4.5/ui/link-picker/form-footer/link-picker-submit-button/index.d.ts +33 -0
- package/dist/{types/ui/link-picker/form-footer → types-ts4.5/ui/link-picker/form-footer/link-picker-submit-button}/utils.d.ts +1 -1
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/list-item/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/list-item/styled.d.ts +0 -1
- package/package.json +2 -2
- /package/dist/cjs/ui/link-picker/form-footer/{utils.js → link-picker-submit-button/utils.js} +0 -0
- /package/dist/es2019/ui/link-picker/form-footer/{utils.js → link-picker-submit-button/utils.js} +0 -0
- /package/dist/esm/ui/link-picker/form-footer/{utils.js → link-picker-submit-button/utils.js} +0 -0
|
@@ -3,15 +3,17 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
* @jsxRuntime classic
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
|
-
import { Fragment, memo, useCallback, useLayoutEffect, useReducer } from 'react';
|
|
6
|
+
import { Fragment, memo, useCallback, useLayoutEffect, useMemo, useReducer } from 'react';
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { jsx } from '@emotion/react';
|
|
10
10
|
import { FormattedMessage, useIntl } from 'react-intl-next';
|
|
11
|
+
import uuid from 'uuid';
|
|
11
12
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
12
13
|
import { isSafeUrl, normalizeUrl } from '@atlaskit/linking-common/url';
|
|
13
14
|
import { browser } from '@atlaskit/linking-common/user-agent';
|
|
14
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
15
17
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
16
18
|
import { useLinkPickerAnalytics, withInputFieldTracking, withLinkPickerAnalyticsContext } from '../../common/analytics';
|
|
17
19
|
import { ANALYTICS_CHANNEL } from '../../common/constants';
|
|
@@ -21,6 +23,7 @@ import { usePlugins } from '../../services/use-plugins';
|
|
|
21
23
|
import { useSearchQuery } from '../../services/use-search-query';
|
|
22
24
|
import { Announcer } from './announcer';
|
|
23
25
|
import { FormFooter, testIds as formFooterTestIds } from './form-footer';
|
|
26
|
+
import { LinkPickerSubmitButton } from './form-footer/link-picker-submit-button';
|
|
24
27
|
import { formMessages, linkMessages, linkTextMessages, searchMessages } from './messages';
|
|
25
28
|
import { SearchResults, testIds as searchTestIds } from './search-results';
|
|
26
29
|
import { formFooterMargin, rootContainerStyles } from './styled';
|
|
@@ -47,6 +50,11 @@ const initState = {
|
|
|
47
50
|
/** This only allows the feature discovery pulse - to be shown the ff must be on and active tab be Jira */
|
|
48
51
|
allowCreateFeatureDiscovery: true
|
|
49
52
|
};
|
|
53
|
+
const FullWidthSubmitButtonStyles = xcss({
|
|
54
|
+
marginTop: 'space.200',
|
|
55
|
+
display: 'flex',
|
|
56
|
+
flexDirection: 'column'
|
|
57
|
+
});
|
|
50
58
|
function reducer(state, payload) {
|
|
51
59
|
if (payload.url && state.url !== payload.url) {
|
|
52
60
|
return {
|
|
@@ -90,7 +98,8 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
90
98
|
hideDisplayText,
|
|
91
99
|
featureFlags,
|
|
92
100
|
customMessages,
|
|
93
|
-
isSubmitting = false
|
|
101
|
+
isSubmitting = false,
|
|
102
|
+
UNSAFE_moveSubmitButton = false
|
|
94
103
|
}) => {
|
|
95
104
|
const {
|
|
96
105
|
createAnalyticsEvent
|
|
@@ -128,6 +137,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
128
137
|
trackAttribute,
|
|
129
138
|
getAttributes
|
|
130
139
|
} = useLinkPickerAnalytics();
|
|
140
|
+
const submitMessageId = useMemo(() => uuid(), []);
|
|
131
141
|
useLayoutEffect(() => {
|
|
132
142
|
if (onContentResize) {
|
|
133
143
|
onContentResize();
|
|
@@ -320,6 +330,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
320
330
|
// as the Aria design pattern for combobox does not work in this case
|
|
321
331
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
322
332
|
const screenReaderText = browser().safari && getScreenReaderText(items !== null && items !== void 0 ? items : [], selectedIndex, intl);
|
|
333
|
+
const customSubmitButtonLabel = customMessages !== null && customMessages !== void 0 && customMessages.submitButtonLabel ? customMessages.submitButtonLabel : undefined;
|
|
323
334
|
return jsx("form", {
|
|
324
335
|
"data-testid": testIds.linkPicker
|
|
325
336
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
@@ -362,7 +373,20 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
362
373
|
readOnly: isSubmitting,
|
|
363
374
|
onClear: handleClear,
|
|
364
375
|
onChange: handleChangeText
|
|
365
|
-
}),
|
|
376
|
+
}), UNSAFE_moveSubmitButton && jsx(Box, {
|
|
377
|
+
xcss: FullWidthSubmitButtonStyles
|
|
378
|
+
}, jsx(LinkPickerSubmitButton, {
|
|
379
|
+
isEditing: isEditing,
|
|
380
|
+
isLoading: isLoadingResults || !!isLoadingPlugins,
|
|
381
|
+
isSubmitting: isSubmitting,
|
|
382
|
+
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
383
|
+
error: error,
|
|
384
|
+
items: items,
|
|
385
|
+
queryState: queryState,
|
|
386
|
+
submitMessageId: submitMessageId,
|
|
387
|
+
testId: testIds.insertButton,
|
|
388
|
+
url: url
|
|
389
|
+
})), !!queryState && (isLoadingPlugins || isActivePlugin) && jsx(SearchResults, {
|
|
366
390
|
activeTab: activeTab,
|
|
367
391
|
tabs: tabs,
|
|
368
392
|
activePlugin: activePlugin,
|
|
@@ -398,6 +422,8 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
398
422
|
/* Show the feature discovery pulse when we're on the Jira tab, we haven't started typing a url and
|
|
399
423
|
the feature flag is enabled */,
|
|
400
424
|
createFeatureDiscovery: (activePlugin === null || activePlugin === void 0 ? void 0 : activePlugin.tabKey) === 'jira' && allowCreateFeatureDiscovery && fg('platform.linking-platform.link-picker.enable-jira-create'),
|
|
401
|
-
customSubmitButtonLabel:
|
|
425
|
+
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
426
|
+
submitMessageId: submitMessageId,
|
|
427
|
+
hideSubmitButton: UNSAFE_moveSubmitButton
|
|
402
428
|
}));
|
|
403
429
|
}));
|
|
@@ -6,9 +6,10 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
6
6
|
import { forwardRef, Fragment, useCallback, useRef } from 'react';
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
|
-
import {
|
|
9
|
+
import { jsx } from '@emotion/react';
|
|
10
10
|
import { defineMessages, FormattedMessage } from 'react-intl-next';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
12
13
|
import Spinner from '@atlaskit/spinner';
|
|
13
14
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
14
15
|
import { MinHeightContainer } from '../../../../common/ui/min-height-container';
|
|
@@ -42,8 +43,8 @@ export const testIds = {
|
|
|
42
43
|
searchResultLoadingIndicator: 'link-picker.results-loading-indicator',
|
|
43
44
|
tabsLoadingIndicator: 'link-picker.tabs-loading-indicator'
|
|
44
45
|
};
|
|
45
|
-
const emptyStateNoResultsWrapper =
|
|
46
|
-
minHeight:
|
|
46
|
+
const emptyStateNoResultsWrapper = xcss({
|
|
47
|
+
minHeight: 'space.200'
|
|
47
48
|
});
|
|
48
49
|
export const LinkSearchList = /*#__PURE__*/forwardRef(({
|
|
49
50
|
onChange,
|
|
@@ -62,6 +63,7 @@ export const LinkSearchList = /*#__PURE__*/forwardRef(({
|
|
|
62
63
|
activePlugin,
|
|
63
64
|
...restProps
|
|
64
65
|
}, ref) => {
|
|
66
|
+
var _activePlugin$uiOptio;
|
|
65
67
|
let itemsContent;
|
|
66
68
|
let loadingContent;
|
|
67
69
|
const linkListTitle = hasSearchTerm ? messages.titleResults : messages.titleRecentlyViewed;
|
|
@@ -102,20 +104,19 @@ export const LinkSearchList = /*#__PURE__*/forwardRef(({
|
|
|
102
104
|
}, [activeIndex, items, onKeyDown]);
|
|
103
105
|
if ((items === null || items === void 0 ? void 0 : items.length) === 0) {
|
|
104
106
|
if (fg('platform.linking-platform.link-picker.enable-empty-state')) {
|
|
105
|
-
if (hasSearchTerm) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
);
|
|
107
|
+
if (!hasSearchTerm) {
|
|
108
|
+
var _activePlugin$emptySt;
|
|
109
|
+
const emptyState = activePlugin === null || activePlugin === void 0 ? void 0 : (_activePlugin$emptySt = activePlugin.emptyStateNoResults) === null || _activePlugin$emptySt === void 0 ? void 0 : _activePlugin$emptySt.call(activePlugin);
|
|
110
|
+
if (emptyState) {
|
|
111
|
+
return jsx(Box, {
|
|
112
|
+
xcss: emptyStateNoResultsWrapper
|
|
113
|
+
}, emptyState);
|
|
114
|
+
}
|
|
114
115
|
}
|
|
115
|
-
} else {
|
|
116
|
-
return jsx(NoResults, null);
|
|
117
116
|
}
|
|
117
|
+
return jsx(NoResults, null);
|
|
118
118
|
}
|
|
119
|
+
const listItemNameMaxLines = activePlugin === null || activePlugin === void 0 ? void 0 : (_activePlugin$uiOptio = activePlugin.uiOptions) === null || _activePlugin$uiOptio === void 0 ? void 0 : _activePlugin$uiOptio.listItemNameMaxLines;
|
|
119
120
|
if (items && items.length > 0) {
|
|
120
121
|
itemsContent = jsx(Fragment, null, jsx("div", {
|
|
121
122
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
@@ -151,7 +152,8 @@ export const LinkSearchList = /*#__PURE__*/forwardRef(({
|
|
|
151
152
|
onSelect: onSelect,
|
|
152
153
|
key: item.objectId,
|
|
153
154
|
tabIndex: getTabIndex(index),
|
|
154
|
-
ref: el => itemRefCallback(el, item.objectId)
|
|
155
|
+
ref: el => itemRefCallback(el, item.objectId),
|
|
156
|
+
nameMaxLines: listItemNameMaxLines
|
|
155
157
|
}))));
|
|
156
158
|
}
|
|
157
159
|
if (isLoading) {
|
|
@@ -7,9 +7,10 @@ import { forwardRef, Fragment } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { jsx } from '@emotion/react';
|
|
9
9
|
import { useIntl } from 'react-intl-next';
|
|
10
|
+
import { Text } from '@atlaskit/primitives';
|
|
10
11
|
/* eslint-disable-next-line @atlassian/tangerine/import/no-parent-imports */
|
|
11
12
|
import { transformTimeStamp } from '../../../transformTimeStamp';
|
|
12
|
-
import { composeListItemStyles, imgStyles, itemIconStyles, itemNameStyles, listItemContainerInnerStyles, listItemContainerStyles, listItemContextStyles
|
|
13
|
+
import { composeListItemStyles, imgStyles, itemIconStyles, itemNameStyles, listItemContainerInnerStyles, listItemContainerStyles, listItemContextStyles } from './styled';
|
|
13
14
|
export const testIds = {
|
|
14
15
|
searchResultItem: 'link-search-list-item',
|
|
15
16
|
searchResultIcon: 'link-search-list-item-icon'
|
|
@@ -55,6 +56,37 @@ const ListItemIcon = props => {
|
|
|
55
56
|
}))
|
|
56
57
|
);
|
|
57
58
|
};
|
|
59
|
+
const ListItemSubtitle = ({
|
|
60
|
+
items: [firstItem, secondItem]
|
|
61
|
+
}) => {
|
|
62
|
+
return /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766 */(
|
|
63
|
+
jsx("div", {
|
|
64
|
+
"data-testid": `${testIds.searchResultItem}-subtitle`,
|
|
65
|
+
css: listItemContextStyles
|
|
66
|
+
}, jsx("div", {
|
|
67
|
+
css: listItemContainerStyles
|
|
68
|
+
}, jsx("span", {
|
|
69
|
+
css: listItemContainerInnerStyles
|
|
70
|
+
}, firstItem)), secondItem && jsx("div", {
|
|
71
|
+
css: listItemContainerInnerStyles
|
|
72
|
+
}, jsx(Fragment, null, "\xA0 \u2022\xA0 "), jsx(Fragment, null, secondItem)))
|
|
73
|
+
);
|
|
74
|
+
/* eslint-enable @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766 */
|
|
75
|
+
};
|
|
76
|
+
const getDefaultSubtitleItems = (item, intl) => {
|
|
77
|
+
const container = item.container;
|
|
78
|
+
const date = transformTimeStamp(intl, item.lastViewedDate, item.lastUpdatedDate);
|
|
79
|
+
if (container) {
|
|
80
|
+
if (date) {
|
|
81
|
+
return [container, date];
|
|
82
|
+
}
|
|
83
|
+
return [container];
|
|
84
|
+
}
|
|
85
|
+
if (date) {
|
|
86
|
+
return [date];
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
};
|
|
58
90
|
export const LinkSearchListItem = /*#__PURE__*/forwardRef(({
|
|
59
91
|
item,
|
|
60
92
|
selected,
|
|
@@ -63,12 +95,12 @@ export const LinkSearchListItem = /*#__PURE__*/forwardRef(({
|
|
|
63
95
|
onSelect,
|
|
64
96
|
tabIndex,
|
|
65
97
|
onKeyDown,
|
|
66
|
-
onFocus
|
|
98
|
+
onFocus,
|
|
99
|
+
nameMaxLines = 1
|
|
67
100
|
}, ref) => {
|
|
68
101
|
const intl = useIntl();
|
|
69
102
|
const handleSelect = () => onSelect(item.objectId);
|
|
70
|
-
const
|
|
71
|
-
const date = transformTimeStamp(intl, item.lastViewedDate, item.lastUpdatedDate);
|
|
103
|
+
const subtitleItems = item.subtitleItems || getDefaultSubtitleItems(item, intl);
|
|
72
104
|
return jsx("div", {
|
|
73
105
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
74
106
|
css: composeListItemStyles(selected),
|
|
@@ -86,24 +118,12 @@ export const LinkSearchListItem = /*#__PURE__*/forwardRef(({
|
|
|
86
118
|
intl: intl
|
|
87
119
|
}), jsx("div", {
|
|
88
120
|
css: itemNameStyles
|
|
89
|
-
}, jsx(
|
|
90
|
-
|
|
91
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
92
|
-
,
|
|
93
|
-
css: listItemNameStyles,
|
|
94
|
-
title: item.name
|
|
95
|
-
}, item.name), jsx("div", {
|
|
96
|
-
"data-testid": `${testIds.searchResultItem}-subtitle`,
|
|
97
|
-
css: listItemContextStyles
|
|
98
|
-
}, container &&
|
|
99
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
100
|
-
jsx("div", {
|
|
101
|
-
css: listItemContainerStyles
|
|
121
|
+
}, jsx(Text, {
|
|
122
|
+
maxLines: nameMaxLines
|
|
102
123
|
}, jsx("span", {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, container && jsx(Fragment, null, "\xA0 \u2022\xA0 "), jsx(Fragment, null, date)))));
|
|
124
|
+
"data-testid": `${testIds.searchResultItem}-title`,
|
|
125
|
+
title: item.name
|
|
126
|
+
}, item.name)), subtitleItems && jsx(ListItemSubtitle, {
|
|
127
|
+
items: subtitleItems
|
|
128
|
+
})));
|
|
109
129
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
|
-
import { B100, B400, B50, N20, N200, N300
|
|
3
|
+
import { B100, B400, B50, N20, N200, N300 } from '@atlaskit/theme/colors';
|
|
4
4
|
import { fontSize, fontSizeSmall } from '@atlaskit/theme/constants';
|
|
5
5
|
// AFP-2532 TODO: Fix automatic suppressions below
|
|
6
6
|
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
@@ -60,16 +60,8 @@ export const composeListItemStyles = (selected = false) => {
|
|
|
60
60
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
61
61
|
export const itemNameStyles = css({
|
|
62
62
|
overflow: 'hidden',
|
|
63
|
-
alignContent: 'center'
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
67
|
-
export const listItemNameStyles = css({
|
|
68
|
-
color: `var(--ds-text, ${N800})`,
|
|
69
|
-
overflow: 'hidden',
|
|
70
|
-
textOverflow: 'ellipsis',
|
|
71
|
-
whiteSpace: 'nowrap',
|
|
72
|
-
lineHeight: '20px'
|
|
63
|
+
alignContent: 'center',
|
|
64
|
+
width: '100%'
|
|
73
65
|
});
|
|
74
66
|
|
|
75
67
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
package/dist/es2019/ui/main.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["isLoading", "isSubmitting", "error", "url", "queryState", "items", "isEditing", "onCancel", "action", "createFeatureDiscovery", "customSubmitButtonLabel"];
|
|
3
|
+
var _excluded = ["isLoading", "isSubmitting", "error", "url", "queryState", "items", "isEditing", "onCancel", "action", "createFeatureDiscovery", "customSubmitButtonLabel", "submitMessageId", "hideSubmitButton"];
|
|
4
4
|
/**
|
|
5
5
|
* @jsxRuntime classic
|
|
6
6
|
* @jsx jsx
|
|
7
7
|
*/
|
|
8
|
-
import { memo
|
|
8
|
+
import { memo } from 'react';
|
|
9
9
|
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { css, jsx } from '@emotion/react';
|
|
12
12
|
import { defineMessages, useIntl } from 'react-intl-next';
|
|
13
|
-
import uuid from 'uuid';
|
|
14
13
|
import Button, { ButtonGroup } from '@atlaskit/button';
|
|
15
|
-
import LoadingButton from '@atlaskit/button/loading-button';
|
|
16
14
|
import EditorAddIconLegacy from '@atlaskit/icon/glyph/editor/add';
|
|
17
15
|
import EditorAddIcon from '@atlaskit/icon/utility/add';
|
|
18
16
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
19
17
|
import { UnauthenticatedError } from '../../../common/utils/errors';
|
|
20
18
|
import FeatureDiscovery from './feature-discovery';
|
|
21
|
-
import {
|
|
19
|
+
import { LinkPickerSubmitButton } from './link-picker-submit-button';
|
|
22
20
|
var formFooterStyles = css({
|
|
23
21
|
display: 'flex',
|
|
24
22
|
justifyContent: 'flex-end'
|
|
@@ -32,16 +30,6 @@ export var messages = defineMessages({
|
|
|
32
30
|
defaultMessage: 'Cancel',
|
|
33
31
|
description: 'Button to cancel and dismiss the link picker'
|
|
34
32
|
},
|
|
35
|
-
saveButton: {
|
|
36
|
-
id: 'fabric.linkPicker.button.save',
|
|
37
|
-
defaultMessage: 'Save',
|
|
38
|
-
description: 'Button to save edited link'
|
|
39
|
-
},
|
|
40
|
-
insertButton: {
|
|
41
|
-
id: 'fabric.linkPicker.button.insert',
|
|
42
|
-
defaultMessage: 'Insert',
|
|
43
|
-
description: 'Button to insert searched or selected link'
|
|
44
|
-
},
|
|
45
33
|
submittingStatusMessage: {
|
|
46
34
|
id: 'fabric.linkPicker.status.submitting',
|
|
47
35
|
defaultMessage: 'Submitting',
|
|
@@ -70,16 +58,13 @@ export var FormFooter = /*#__PURE__*/memo(function (_ref) {
|
|
|
70
58
|
_ref$createFeatureDis = _ref.createFeatureDiscovery,
|
|
71
59
|
createFeatureDiscovery = _ref$createFeatureDis === void 0 ? false : _ref$createFeatureDis,
|
|
72
60
|
customSubmitButtonLabel = _ref.customSubmitButtonLabel,
|
|
61
|
+
submitMessageId = _ref.submitMessageId,
|
|
62
|
+
hideSubmitButton = _ref.hideSubmitButton,
|
|
73
63
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
74
64
|
var intl = useIntl();
|
|
75
|
-
var submitMessageId = useMemo(function () {
|
|
76
|
-
return uuid();
|
|
77
|
-
}, []);
|
|
78
65
|
if (error && error instanceof UnauthenticatedError) {
|
|
79
66
|
return null;
|
|
80
67
|
}
|
|
81
|
-
var isSubmitDisabled = checkSubmitDisabled(isLoading, isSubmitting, error, url, queryState, items);
|
|
82
|
-
var insertButtonMsg = isEditing ? messages.saveButton : messages.insertButton;
|
|
83
68
|
var createButton = function createButton(pluginAction) {
|
|
84
69
|
return jsx(Button, {
|
|
85
70
|
testId: testIds.actionButton,
|
|
@@ -111,12 +96,16 @@ export var FormFooter = /*#__PURE__*/memo(function (_ref) {
|
|
|
111
96
|
testId: testIds.cancelButton,
|
|
112
97
|
isDisabled: isSubmitting,
|
|
113
98
|
"aria-labelledby": isSubmitting ? submitMessageId : undefined
|
|
114
|
-
}, intl.formatMessage(messages.cancelButton)), jsx(
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
}, intl.formatMessage(messages.cancelButton)), !hideSubmitButton && jsx(LinkPickerSubmitButton, {
|
|
100
|
+
isEditing: isEditing,
|
|
101
|
+
isLoading: isLoading,
|
|
102
|
+
isSubmitting: isSubmitting,
|
|
103
|
+
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
104
|
+
error: error,
|
|
105
|
+
items: items,
|
|
106
|
+
queryState: queryState,
|
|
107
|
+
submitMessageId: submitMessageId,
|
|
117
108
|
testId: testIds.insertButton,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
isLoading: isSubmitting
|
|
121
|
-
}, customSubmitButtonLabel ? intl.formatMessage(customSubmitButtonLabel) : intl.formatMessage(insertButtonMsg))));
|
|
109
|
+
url: url
|
|
110
|
+
})));
|
|
122
111
|
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
|
+
import { jsx } from '@emotion/react';
|
|
7
|
+
import { defineMessages, useIntl } from 'react-intl-next';
|
|
8
|
+
import LoadingButton from '@atlaskit/button/loading-button';
|
|
9
|
+
import { checkSubmitDisabled } from './utils';
|
|
10
|
+
export var messages = defineMessages({
|
|
11
|
+
saveButton: {
|
|
12
|
+
id: 'fabric.linkPicker.button.save',
|
|
13
|
+
defaultMessage: 'Save',
|
|
14
|
+
description: 'Button to save edited link'
|
|
15
|
+
},
|
|
16
|
+
insertButton: {
|
|
17
|
+
id: 'fabric.linkPicker.button.insert',
|
|
18
|
+
defaultMessage: 'Insert',
|
|
19
|
+
description: 'Button to insert searched or selected link'
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export var LinkPickerSubmitButton = function LinkPickerSubmitButton(_ref) {
|
|
23
|
+
var isEditing = _ref.isEditing,
|
|
24
|
+
isLoading = _ref.isLoading,
|
|
25
|
+
isSubmitting = _ref.isSubmitting,
|
|
26
|
+
customSubmitButtonLabel = _ref.customSubmitButtonLabel,
|
|
27
|
+
error = _ref.error,
|
|
28
|
+
items = _ref.items,
|
|
29
|
+
queryState = _ref.queryState,
|
|
30
|
+
submitMessageId = _ref.submitMessageId,
|
|
31
|
+
testId = _ref.testId,
|
|
32
|
+
url = _ref.url;
|
|
33
|
+
var intl = useIntl();
|
|
34
|
+
var insertButtonMsg = isEditing ? messages.saveButton : messages.insertButton;
|
|
35
|
+
var isSubmitDisabled = checkSubmitDisabled(isLoading, isSubmitting, error, url, queryState, items);
|
|
36
|
+
return jsx(LoadingButton, {
|
|
37
|
+
type: "submit",
|
|
38
|
+
appearance: "primary",
|
|
39
|
+
testId: testId,
|
|
40
|
+
isDisabled: isSubmitDisabled,
|
|
41
|
+
"aria-labelledby": isSubmitting ? submitMessageId : undefined,
|
|
42
|
+
isLoading: isSubmitting
|
|
43
|
+
}, customSubmitButtonLabel ? intl.formatMessage(customSubmitButtonLabel) : intl.formatMessage(insertButtonMsg));
|
|
44
|
+
};
|
|
@@ -7,15 +7,17 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
* @jsxRuntime classic
|
|
8
8
|
* @jsx jsx
|
|
9
9
|
*/
|
|
10
|
-
import { Fragment, memo, useCallback, useLayoutEffect, useReducer } from 'react';
|
|
10
|
+
import { Fragment, memo, useCallback, useLayoutEffect, useMemo, useReducer } from 'react';
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
13
|
import { jsx } from '@emotion/react';
|
|
14
14
|
import { FormattedMessage, useIntl } from 'react-intl-next';
|
|
15
|
+
import uuid from 'uuid';
|
|
15
16
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
16
17
|
import { isSafeUrl, normalizeUrl } from '@atlaskit/linking-common/url';
|
|
17
18
|
import { browser } from '@atlaskit/linking-common/user-agent';
|
|
18
19
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
19
21
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
20
22
|
import { useLinkPickerAnalytics, withInputFieldTracking, withLinkPickerAnalyticsContext } from '../../common/analytics';
|
|
21
23
|
import { ANALYTICS_CHANNEL } from '../../common/constants';
|
|
@@ -25,6 +27,7 @@ import { usePlugins } from '../../services/use-plugins';
|
|
|
25
27
|
import { useSearchQuery } from '../../services/use-search-query';
|
|
26
28
|
import { Announcer } from './announcer';
|
|
27
29
|
import { FormFooter, testIds as formFooterTestIds } from './form-footer';
|
|
30
|
+
import { LinkPickerSubmitButton } from './form-footer/link-picker-submit-button';
|
|
28
31
|
import { formMessages, linkMessages, linkTextMessages, searchMessages } from './messages';
|
|
29
32
|
import { SearchResults, testIds as searchTestIds } from './search-results';
|
|
30
33
|
import { formFooterMargin, rootContainerStyles } from './styled';
|
|
@@ -48,6 +51,11 @@ var initState = {
|
|
|
48
51
|
/** This only allows the feature discovery pulse - to be shown the ff must be on and active tab be Jira */
|
|
49
52
|
allowCreateFeatureDiscovery: true
|
|
50
53
|
};
|
|
54
|
+
var FullWidthSubmitButtonStyles = xcss({
|
|
55
|
+
marginTop: 'space.200',
|
|
56
|
+
display: 'flex',
|
|
57
|
+
flexDirection: 'column'
|
|
58
|
+
});
|
|
51
59
|
function reducer(state, payload) {
|
|
52
60
|
if (payload.url && state.url !== payload.url) {
|
|
53
61
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -88,7 +96,9 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
88
96
|
featureFlags = _ref.featureFlags,
|
|
89
97
|
customMessages = _ref.customMessages,
|
|
90
98
|
_ref$isSubmitting = _ref.isSubmitting,
|
|
91
|
-
isSubmitting = _ref$isSubmitting === void 0 ? false : _ref$isSubmitting
|
|
99
|
+
isSubmitting = _ref$isSubmitting === void 0 ? false : _ref$isSubmitting,
|
|
100
|
+
_ref$UNSAFE_moveSubmi = _ref.UNSAFE_moveSubmitButton,
|
|
101
|
+
UNSAFE_moveSubmitButton = _ref$UNSAFE_moveSubmi === void 0 ? false : _ref$UNSAFE_moveSubmi;
|
|
92
102
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
93
103
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
94
104
|
var _useReducer = useReducer(reducer, _objectSpread(_objectSpread({}, initState), {}, {
|
|
@@ -122,6 +132,9 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
122
132
|
var _useLinkPickerAnalyti = useLinkPickerAnalytics(),
|
|
123
133
|
trackAttribute = _useLinkPickerAnalyti.trackAttribute,
|
|
124
134
|
getAttributes = _useLinkPickerAnalyti.getAttributes;
|
|
135
|
+
var submitMessageId = useMemo(function () {
|
|
136
|
+
return uuid();
|
|
137
|
+
}, []);
|
|
125
138
|
useLayoutEffect(function () {
|
|
126
139
|
if (onContentResize) {
|
|
127
140
|
onContentResize();
|
|
@@ -312,6 +325,7 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
312
325
|
// as the Aria design pattern for combobox does not work in this case
|
|
313
326
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
314
327
|
var screenReaderText = browser().safari && getScreenReaderText(items !== null && items !== void 0 ? items : [], selectedIndex, intl);
|
|
328
|
+
var customSubmitButtonLabel = customMessages !== null && customMessages !== void 0 && customMessages.submitButtonLabel ? customMessages.submitButtonLabel : undefined;
|
|
315
329
|
return jsx("form", {
|
|
316
330
|
"data-testid": testIds.linkPicker
|
|
317
331
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
@@ -354,7 +368,20 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
354
368
|
readOnly: isSubmitting,
|
|
355
369
|
onClear: handleClear,
|
|
356
370
|
onChange: handleChangeText
|
|
357
|
-
}),
|
|
371
|
+
}), UNSAFE_moveSubmitButton && jsx(Box, {
|
|
372
|
+
xcss: FullWidthSubmitButtonStyles
|
|
373
|
+
}, jsx(LinkPickerSubmitButton, {
|
|
374
|
+
isEditing: isEditing,
|
|
375
|
+
isLoading: isLoadingResults || !!isLoadingPlugins,
|
|
376
|
+
isSubmitting: isSubmitting,
|
|
377
|
+
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
378
|
+
error: error,
|
|
379
|
+
items: items,
|
|
380
|
+
queryState: queryState,
|
|
381
|
+
submitMessageId: submitMessageId,
|
|
382
|
+
testId: testIds.insertButton,
|
|
383
|
+
url: url
|
|
384
|
+
})), !!queryState && (isLoadingPlugins || isActivePlugin) && jsx(SearchResults, {
|
|
358
385
|
activeTab: activeTab,
|
|
359
386
|
tabs: tabs,
|
|
360
387
|
activePlugin: activePlugin,
|
|
@@ -390,6 +417,8 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
390
417
|
/* Show the feature discovery pulse when we're on the Jira tab, we haven't started typing a url and
|
|
391
418
|
the feature flag is enabled */,
|
|
392
419
|
createFeatureDiscovery: (activePlugin === null || activePlugin === void 0 ? void 0 : activePlugin.tabKey) === 'jira' && allowCreateFeatureDiscovery && fg('platform.linking-platform.link-picker.enable-jira-create'),
|
|
393
|
-
customSubmitButtonLabel:
|
|
420
|
+
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
421
|
+
submitMessageId: submitMessageId,
|
|
422
|
+
hideSubmitButton: UNSAFE_moveSubmitButton
|
|
394
423
|
}));
|
|
395
424
|
}));
|
|
@@ -11,9 +11,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
11
11
|
import { forwardRef, Fragment, useCallback, useRef } from 'react';
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
14
|
-
import {
|
|
14
|
+
import { jsx } from '@emotion/react';
|
|
15
15
|
import { defineMessages, FormattedMessage } from 'react-intl-next';
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
17
18
|
import Spinner from '@atlaskit/spinner';
|
|
18
19
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
19
20
|
import { MinHeightContainer } from '../../../../common/ui/min-height-container';
|
|
@@ -45,10 +46,11 @@ export var testIds = _objectSpread(_objectSpread(_objectSpread({}, noResultsTest
|
|
|
45
46
|
searchResultLoadingIndicator: 'link-picker.results-loading-indicator',
|
|
46
47
|
tabsLoadingIndicator: 'link-picker.tabs-loading-indicator'
|
|
47
48
|
});
|
|
48
|
-
var emptyStateNoResultsWrapper =
|
|
49
|
-
minHeight:
|
|
49
|
+
var emptyStateNoResultsWrapper = xcss({
|
|
50
|
+
minHeight: 'space.200'
|
|
50
51
|
});
|
|
51
52
|
export var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
53
|
+
var _activePlugin$uiOptio;
|
|
52
54
|
var onChange = _ref.onChange,
|
|
53
55
|
onSelect = _ref.onSelect,
|
|
54
56
|
onKeyDown = _ref.onKeyDown,
|
|
@@ -104,20 +106,19 @@ export var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
104
106
|
}, [activeIndex, items, onKeyDown]);
|
|
105
107
|
if ((items === null || items === void 0 ? void 0 : items.length) === 0) {
|
|
106
108
|
if (fg('platform.linking-platform.link-picker.enable-empty-state')) {
|
|
107
|
-
if (hasSearchTerm) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
);
|
|
109
|
+
if (!hasSearchTerm) {
|
|
110
|
+
var _activePlugin$emptySt;
|
|
111
|
+
var emptyState = activePlugin === null || activePlugin === void 0 || (_activePlugin$emptySt = activePlugin.emptyStateNoResults) === null || _activePlugin$emptySt === void 0 ? void 0 : _activePlugin$emptySt.call(activePlugin);
|
|
112
|
+
if (emptyState) {
|
|
113
|
+
return jsx(Box, {
|
|
114
|
+
xcss: emptyStateNoResultsWrapper
|
|
115
|
+
}, emptyState);
|
|
116
|
+
}
|
|
116
117
|
}
|
|
117
|
-
} else {
|
|
118
|
-
return jsx(NoResults, null);
|
|
119
118
|
}
|
|
119
|
+
return jsx(NoResults, null);
|
|
120
120
|
}
|
|
121
|
+
var listItemNameMaxLines = activePlugin === null || activePlugin === void 0 || (_activePlugin$uiOptio = activePlugin.uiOptions) === null || _activePlugin$uiOptio === void 0 ? void 0 : _activePlugin$uiOptio.listItemNameMaxLines;
|
|
121
122
|
if (items && items.length > 0) {
|
|
122
123
|
itemsContent = jsx(Fragment, null, jsx("div", {
|
|
123
124
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
@@ -158,7 +159,8 @@ export var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
158
159
|
tabIndex: getTabIndex(index),
|
|
159
160
|
ref: function ref(el) {
|
|
160
161
|
return itemRefCallback(el, item.objectId);
|
|
161
|
-
}
|
|
162
|
+
},
|
|
163
|
+
nameMaxLines: listItemNameMaxLines
|
|
162
164
|
});
|
|
163
165
|
})));
|
|
164
166
|
}
|