@atlaskit/link-picker 1.4.0 → 1.5.1
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 +19 -0
- package/dist/cjs/services/use-plugins/index.js +201 -0
- package/dist/cjs/ui/link-picker/index.js +308 -599
- package/dist/cjs/ui/link-picker/link-search-list/index.js +54 -82
- package/dist/cjs/ui/link-picker/list-item/index.js +5 -3
- package/dist/cjs/ui/link-picker/styled.js +5 -3
- package/dist/cjs/ui/link-picker/text-input/index.js +6 -4
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/services/use-plugins/index.js +122 -0
- package/dist/es2019/ui/link-picker/index.js +288 -467
- package/dist/es2019/ui/link-picker/link-search-list/index.js +49 -50
- package/dist/es2019/ui/link-picker/list-item/index.js +4 -3
- package/dist/es2019/ui/link-picker/styled.js +4 -0
- package/dist/es2019/ui/link-picker/text-input/index.js +5 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/services/use-plugins/index.js +187 -0
- package/dist/esm/ui/link-picker/index.js +298 -601
- package/dist/esm/ui/link-picker/link-search-list/index.js +51 -79
- package/dist/esm/ui/link-picker/list-item/index.js +4 -3
- package/dist/esm/ui/link-picker/styled.js +3 -2
- package/dist/esm/ui/link-picker/text-input/index.js +5 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/services/use-plugins/index.d.ts +12 -0
- package/dist/types/ui/link-picker/index.d.ts +24 -13
- package/dist/types/ui/link-picker/link-search-list/index.d.ts +3 -5
- package/dist/types/ui/link-picker/styled.d.ts +1 -0
- package/dist/types/ui/link-picker/text-input/index.d.ts +1 -1
- package/package.json +4 -3
|
@@ -1,88 +1,60 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
|
|
9
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
1
|
/** @jsx jsx */
|
|
12
|
-
import { PureComponent } from 'react';
|
|
13
2
|
import { jsx } from '@emotion/react';
|
|
14
3
|
import Spinner from '@atlaskit/spinner';
|
|
15
4
|
import LinkSearchListItem from '../list-item';
|
|
16
5
|
import { listContainerStyles, spinnerContainerStyles, listStyles } from './styled';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
import { testIds } from '../';
|
|
7
|
+
|
|
8
|
+
var LinkSearchList = function LinkSearchList(_ref) {
|
|
9
|
+
var onSelect = _ref.onSelect,
|
|
10
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
11
|
+
onMouseLeave = _ref.onMouseLeave,
|
|
12
|
+
items = _ref.items,
|
|
13
|
+
activeIndex = _ref.activeIndex,
|
|
14
|
+
selectedIndex = _ref.selectedIndex,
|
|
15
|
+
isLoading = _ref.isLoading,
|
|
16
|
+
ariaControls = _ref.ariaControls,
|
|
17
|
+
ariaLabelledBy = _ref.ariaLabelledBy,
|
|
18
|
+
role = _ref.role,
|
|
19
|
+
id = _ref.id;
|
|
20
|
+
var itemsContent;
|
|
21
|
+
var loadingContent;
|
|
22
|
+
|
|
23
|
+
if (items && items.length > 0) {
|
|
24
|
+
itemsContent = jsx("ul", {
|
|
25
|
+
id: id,
|
|
26
|
+
role: role,
|
|
27
|
+
css: listStyles,
|
|
28
|
+
"aria-controls": ariaControls,
|
|
29
|
+
"aria-labelledby": ariaLabelledBy,
|
|
30
|
+
"data-testid": testIds.searchResultList
|
|
31
|
+
}, items.map(function (item, index) {
|
|
32
|
+
return jsx(LinkSearchListItem, {
|
|
33
|
+
id: "".concat(testIds.searchResultItem, "-").concat(index),
|
|
34
|
+
role: role && 'option',
|
|
35
|
+
item: item,
|
|
36
|
+
selected: selectedIndex === index,
|
|
37
|
+
active: activeIndex === index,
|
|
38
|
+
onMouseEnter: onMouseEnter,
|
|
39
|
+
onMouseLeave: onMouseLeave,
|
|
40
|
+
onSelect: onSelect,
|
|
41
|
+
key: item.objectId
|
|
42
|
+
});
|
|
43
|
+
}));
|
|
27
44
|
}
|
|
28
45
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
activeIndex = _this$props.activeIndex,
|
|
38
|
-
selectedIndex = _this$props.selectedIndex,
|
|
39
|
-
isLoading = _this$props.isLoading,
|
|
40
|
-
ariaControls = _this$props.ariaControls,
|
|
41
|
-
ariaLabelledBy = _this$props.ariaLabelledBy,
|
|
42
|
-
role = _this$props.role,
|
|
43
|
-
id = _this$props.id;
|
|
44
|
-
var itemsContent;
|
|
45
|
-
var loadingContent;
|
|
46
|
-
|
|
47
|
-
if (items && items.length > 0) {
|
|
48
|
-
itemsContent = jsx("ul", {
|
|
49
|
-
"data-testid": "link-search-list",
|
|
50
|
-
css: listStyles,
|
|
51
|
-
id: id,
|
|
52
|
-
role: role,
|
|
53
|
-
"aria-controls": ariaControls,
|
|
54
|
-
"aria-labelledby": ariaLabelledBy
|
|
55
|
-
}, items.map(function (item, index) {
|
|
56
|
-
return jsx(LinkSearchListItem, {
|
|
57
|
-
id: "link-search-list-item-".concat(index),
|
|
58
|
-
role: role && 'option',
|
|
59
|
-
item: item,
|
|
60
|
-
selected: selectedIndex === index,
|
|
61
|
-
active: activeIndex === index,
|
|
62
|
-
onMouseEnter: onMouseEnter,
|
|
63
|
-
onMouseLeave: onMouseLeave,
|
|
64
|
-
onSelect: onSelect,
|
|
65
|
-
key: item.objectId
|
|
66
|
-
});
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (isLoading) {
|
|
71
|
-
loadingContent = jsx("div", {
|
|
72
|
-
css: spinnerContainerStyles
|
|
73
|
-
}, jsx(Spinner, {
|
|
74
|
-
testId: "link-picker.results-loading-indicator",
|
|
75
|
-
size: "medium"
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return jsx("div", {
|
|
80
|
-
css: listContainerStyles
|
|
81
|
-
}, itemsContent, loadingContent);
|
|
82
|
-
}
|
|
83
|
-
}]);
|
|
46
|
+
if (isLoading) {
|
|
47
|
+
loadingContent = jsx("div", {
|
|
48
|
+
css: spinnerContainerStyles
|
|
49
|
+
}, jsx(Spinner, {
|
|
50
|
+
testId: testIds.searchResultLoadingIndicator,
|
|
51
|
+
size: "medium"
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
84
54
|
|
|
85
|
-
return
|
|
86
|
-
|
|
55
|
+
return jsx("div", {
|
|
56
|
+
css: listContainerStyles
|
|
57
|
+
}, itemsContent, loadingContent);
|
|
58
|
+
};
|
|
87
59
|
|
|
88
|
-
export
|
|
60
|
+
export default LinkSearchList;
|
|
@@ -4,6 +4,7 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import { injectIntl } from 'react-intl-next';
|
|
5
5
|
import { transformTimeStamp } from '../transformTimeStamp';
|
|
6
6
|
import { itemNameStyles, itemIconStyles, listItemContextStyles, listItemNameStyles, composeListItemStyles, imgStyles } from './styled';
|
|
7
|
+
import { testIds } from '../';
|
|
7
8
|
|
|
8
9
|
var LinkSearchListItem = function LinkSearchListItem(_ref) {
|
|
9
10
|
var item = _ref.item,
|
|
@@ -35,7 +36,7 @@ var LinkSearchListItem = function LinkSearchListItem(_ref) {
|
|
|
35
36
|
role: role,
|
|
36
37
|
id: id,
|
|
37
38
|
"aria-selected": selected,
|
|
38
|
-
"data-testid":
|
|
39
|
+
"data-testid": testIds.searchResultItem,
|
|
39
40
|
onMouseEnter: handleMouseEnter,
|
|
40
41
|
onMouseLeave: handleMouseLeave,
|
|
41
42
|
onClick: handleSelect
|
|
@@ -45,10 +46,10 @@ var LinkSearchListItem = function LinkSearchListItem(_ref) {
|
|
|
45
46
|
}), jsx("div", {
|
|
46
47
|
css: itemNameStyles
|
|
47
48
|
}, jsx("div", {
|
|
48
|
-
"data-testid": "
|
|
49
|
+
"data-testid": "".concat(testIds.searchResultItem, "-title"),
|
|
49
50
|
css: listItemNameStyles
|
|
50
51
|
}, item.name), jsx("div", {
|
|
51
|
-
"data-testid": "
|
|
52
|
+
"data-testid": "".concat(testIds.searchResultItem, "-subtitle"),
|
|
52
53
|
css: listItemContextStyles
|
|
53
54
|
}, container, container && date && jsx(Fragment, null, "\xA0 \u2022\xA0 "), date && jsx(Fragment, null, formatDate(date)))));
|
|
54
55
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
4
4
|
|
|
5
5
|
import { token } from '@atlaskit/tokens';
|
|
6
6
|
import { css } from '@emotion/react';
|
|
@@ -14,4 +14,5 @@ var LINK_PICKER_MIN_HEIGHT_IN_PX = 234;
|
|
|
14
14
|
export var rootContainerStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n padding: ", "px;\n box-sizing: border-box;\n line-height: initial;\n min-height: ", "px;\n"])), LINK_PICKER_WIDTH_IN_PX, gridSize() * 2, LINK_PICKER_MIN_HEIGHT_IN_PX);
|
|
15
15
|
export var rootContainerStylesForLoader = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n display: flex;\n align-items: center;\n justify-content: center;\n"])), rootContainerStyles);
|
|
16
16
|
export var searchIconStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-left: ", "px;\n color: ", ";\n cursor: default;\n"])), gridSize() / 2, token('color.icon', N500));
|
|
17
|
-
export var listTitleStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n text-transform: uppercase;\n margin-bottom: ", "px;\n"])), typography.h100(), gridSize() / 2);
|
|
17
|
+
export var listTitleStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n text-transform: uppercase;\n margin-bottom: ", "px;\n"])), typography.h100(), gridSize() / 2);
|
|
18
|
+
export var tabsWrapperStyles = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-left: -", "px;\n margin-right: -", "px;\n"])), gridSize(), gridSize());
|
|
@@ -11,6 +11,7 @@ import Textfield from '@atlaskit/textfield';
|
|
|
11
11
|
import Selectclear from '@atlaskit/icon/glyph/select-clear';
|
|
12
12
|
import { isRedoEvent, isUndoEvent } from '../utils';
|
|
13
13
|
import { clearTextButtonStyles, fieldStyles } from './styled';
|
|
14
|
+
import { testIds } from '../';
|
|
14
15
|
|
|
15
16
|
var PanelTextInput = function PanelTextInput(props) {
|
|
16
17
|
var name = props.name,
|
|
@@ -64,15 +65,15 @@ var PanelTextInput = function PanelTextInput(props) {
|
|
|
64
65
|
var handleClear = useCallback(function () {
|
|
65
66
|
if (inputRef.current && onClear) {
|
|
66
67
|
inputRef.current.focus();
|
|
67
|
-
onClear();
|
|
68
|
+
onClear(name);
|
|
68
69
|
}
|
|
69
|
-
}, [onClear]);
|
|
70
|
+
}, [name, onClear]);
|
|
70
71
|
var clearText = restProps.value !== '' && jsx(Tooltip, {
|
|
71
72
|
content: clearLabel
|
|
72
73
|
}, jsx("button", {
|
|
73
74
|
css: clearTextButtonStyles,
|
|
74
75
|
onClick: handleClear,
|
|
75
|
-
"data-testid":
|
|
76
|
+
"data-testid": testIds.clearUrlButton
|
|
76
77
|
}, jsx(Selectclear, {
|
|
77
78
|
size: "medium",
|
|
78
79
|
label: clearLabel || ''
|
|
@@ -91,7 +92,7 @@ var PanelTextInput = function PanelTextInput(props) {
|
|
|
91
92
|
elemAfterInput: clearText,
|
|
92
93
|
isInvalid: !!error
|
|
93
94
|
})), error && jsx(ErrorMessage, {
|
|
94
|
-
testId:
|
|
95
|
+
testId: testIds.urlError
|
|
95
96
|
}, error));
|
|
96
97
|
}));
|
|
97
98
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PickerState } from '../../ui/link-picker';
|
|
2
|
+
import { LinkPickerPlugin, LinkSearchListItemData } from '../../ui/types';
|
|
3
|
+
export interface LinkPickerPluginsService {
|
|
4
|
+
items: LinkSearchListItemData[];
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
isSelectedItem: boolean;
|
|
7
|
+
isActivePlugin: boolean;
|
|
8
|
+
tabs: {
|
|
9
|
+
tabTitle: string;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
export declare function usePlugins(state: PickerState, plugins?: LinkPickerPlugin[]): LinkPickerPluginsService;
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { LinkSearchListItemData, LinkInputType, LinkPickerPlugin } from '../types';
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { LinkInputType, LinkPickerPlugin } from '../types';
|
|
4
3
|
export declare const RECENT_SEARCH_LIST_SIZE = 5;
|
|
4
|
+
export declare const testIds: {
|
|
5
|
+
linkPicker: string;
|
|
6
|
+
urlInputField: string;
|
|
7
|
+
textInputField: string;
|
|
8
|
+
searchIcon: string;
|
|
9
|
+
insertButton: string;
|
|
10
|
+
cancelButton: string;
|
|
11
|
+
clearUrlButton: string;
|
|
12
|
+
resultListTitle: string;
|
|
13
|
+
emptyResultPage: string;
|
|
14
|
+
searchResultList: string;
|
|
15
|
+
searchResultItem: string;
|
|
16
|
+
searchResultLoadingIndicator: string;
|
|
17
|
+
urlError: string;
|
|
18
|
+
tabList: string;
|
|
19
|
+
tabItem: string;
|
|
20
|
+
};
|
|
5
21
|
interface Meta {
|
|
6
22
|
/** Indicates how the link was picked. */
|
|
7
23
|
inputMethod: LinkInputType;
|
|
@@ -35,18 +51,13 @@ export interface LinkPickerProps {
|
|
|
35
51
|
/** Plugins that provide link suggestions / search capabilities. */
|
|
36
52
|
plugins?: LinkPickerPlugin[];
|
|
37
53
|
}
|
|
38
|
-
export interface
|
|
39
|
-
items: LinkSearchListItemData[];
|
|
54
|
+
export interface PickerState {
|
|
40
55
|
selectedIndex: number;
|
|
41
56
|
activeIndex: number;
|
|
42
57
|
url: string;
|
|
43
|
-
isLoading: boolean;
|
|
44
|
-
isEditing: boolean;
|
|
45
58
|
displayText: string;
|
|
46
|
-
invalidUrl:
|
|
47
|
-
|
|
59
|
+
invalidUrl: boolean;
|
|
60
|
+
activeTab: number;
|
|
48
61
|
}
|
|
49
|
-
declare
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
export default _default;
|
|
62
|
+
declare function LinkPicker({ onSubmit, onCancel, plugins, url: initUrl, displayText: initDisplayText, }: LinkPickerProps): jsx.JSX.Element;
|
|
63
|
+
export default LinkPicker;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { PureComponent } from 'react';
|
|
3
2
|
import { jsx } from '@emotion/react';
|
|
4
3
|
import { LinkSearchListItemData } from '../../types';
|
|
5
|
-
export interface
|
|
4
|
+
export interface LinkSearchListProps {
|
|
6
5
|
items?: LinkSearchListItemData[];
|
|
7
6
|
isLoading: boolean;
|
|
8
7
|
selectedIndex: number;
|
|
@@ -15,6 +14,5 @@ export interface Props {
|
|
|
15
14
|
role?: string;
|
|
16
15
|
id?: string;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
declare const LinkSearchList: ({ onSelect, onMouseEnter, onMouseLeave, items, activeIndex, selectedIndex, isLoading, ariaControls, ariaLabelledBy, role, id, }: LinkSearchListProps) => jsx.JSX.Element;
|
|
18
|
+
export default LinkSearchList;
|
|
@@ -2,3 +2,4 @@ export declare const rootContainerStyles: import("@emotion/react").SerializedSty
|
|
|
2
2
|
export declare const rootContainerStylesForLoader: import("@emotion/react").SerializedStyles;
|
|
3
3
|
export declare const searchIconStyles: import("@emotion/react").SerializedStyles;
|
|
4
4
|
export declare const listTitleStyles: import("@emotion/react").SerializedStyles;
|
|
5
|
+
export declare const tabsWrapperStyles: import("@emotion/react").SerializedStyles;
|
|
@@ -9,7 +9,7 @@ export interface Props extends Omit<TextFieldProps, 'value' | 'onChange' | 'auto
|
|
|
9
9
|
onSubmit?: (value: string) => void;
|
|
10
10
|
onUndo?: Function;
|
|
11
11
|
onRedo?: Function;
|
|
12
|
-
onClear?:
|
|
12
|
+
onClear?: Function;
|
|
13
13
|
clearLabel?: string;
|
|
14
14
|
error?: string | null;
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Standalone link picker",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
@@ -60,12 +60,13 @@
|
|
|
60
60
|
"@atlaskit/visual-regression": "*",
|
|
61
61
|
"@atlaskit/webdriver-runner": "*",
|
|
62
62
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
63
|
-
"@atlassian/link-picker-atlassian-plugin": "^
|
|
64
|
-
"@atlassian/link-picker-plugins": "^
|
|
63
|
+
"@atlassian/link-picker-atlassian-plugin": "^15.0.0",
|
|
64
|
+
"@atlassian/link-picker-plugins": "^2.0.0",
|
|
65
65
|
"@atlassian/search-provider": "^2.3.0",
|
|
66
66
|
"@testing-library/dom": "^7.7.3",
|
|
67
67
|
"@testing-library/jest-dom": "^4.1.0",
|
|
68
68
|
"@testing-library/react": "^8.0.1",
|
|
69
|
+
"@testing-library/react-hooks": "^1.0.4",
|
|
69
70
|
"@testing-library/user-event": "10.4.0",
|
|
70
71
|
"enzyme": "^3.10.0",
|
|
71
72
|
"fetch-mock": "^8.0.0",
|