@atlaskit/link-picker 1.0.0 → 1.1.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/link-picker
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ba5d8ed23cc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ba5d8ed23cc) - Adds search error message
8
+
3
9
  ## 1.0.0
4
10
 
5
11
  ### Major Changes
@@ -89,14 +89,24 @@ var messages = (0, _reactIntlNext.defineMessages)({
89
89
  description: 'Describes type of items shown in the list for screen-reader users'
90
90
  },
91
91
  cancelButton: {
92
- id: 'fabric.linkPicker.cancel.button',
92
+ id: 'fabric.linkPicker.button.cancel',
93
93
  defaultMessage: 'Cancel',
94
94
  description: 'Button to cancel and dismiss the link picker'
95
95
  },
96
96
  insertButton: {
97
- id: 'fabric.linkPicker.cancel.insert',
97
+ id: 'fabric.linkPicker.button.insert',
98
98
  defaultMessage: 'Insert',
99
99
  description: 'Button to insert searched or selected link'
100
+ },
101
+ noResults: {
102
+ id: 'fabric.linkPicker.search.noResults.heading',
103
+ defaultMessage: 'We couldn’t find anything matching your search.',
104
+ description: 'Heading message shown when a search has no results'
105
+ },
106
+ noResultsDescription: {
107
+ id: 'fabric.linkPicker.search.noResults.description',
108
+ defaultMessage: 'Try again with a different term.',
109
+ description: 'Describes possible action when a search returns no results'
100
110
  }
101
111
  });
102
112
  exports.messages = messages;
@@ -57,6 +57,8 @@ var _search = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/search
57
57
 
58
58
  var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
59
59
 
60
+ var _linkSearchNoResults = _interopRequireDefault(require("./link-search-no-results"));
61
+
60
62
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
61
63
 
62
64
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -495,6 +497,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
495
497
  size: "medium",
496
498
  label: ''
497
499
  }));
500
+ var noResults = activePlugin && !isLoading && !items.length && !(0, _url.isSafeUrl)(url);
498
501
  return (0, _react2.jsx)("div", {
499
502
  "data-testid": "link-picker",
500
503
  className: "recent-list",
@@ -566,6 +569,10 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
566
569
  onSelect: this.handleSelected,
567
570
  onMouseEnter: this.handleMouseEnterResultItem,
568
571
  onMouseLeave: this.handleMouseLeaveResultItem
572
+ }), noResults && (0, _react2.jsx)(_linkSearchNoResults.default, {
573
+ testId: "link-search-no-results",
574
+ header: formatMessage(_messages.messages.noResults),
575
+ description: formatMessage(_messages.messages.noResultsDescription)
569
576
  }), (0, _react2.jsx)(_form.FormFooter, {
570
577
  align: "end"
571
578
  }, (0, _react2.jsx)(_button.ButtonGroup, null, (0, _react2.jsx)(_button.default, {
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ var _emptyState = _interopRequireDefault(require("@atlaskit/empty-state"));
15
+
16
+ var _noResults = _interopRequireDefault(require("./no-results.svg"));
17
+
18
+ var NoResults = function NoResults(props) {
19
+ return /*#__PURE__*/_react.default.createElement(_emptyState.default, (0, _extends2.default)({}, props, {
20
+ imageUrl: _noResults.default,
21
+ maxImageWidth: 130,
22
+ maxImageHeight: 130
23
+ }));
24
+ };
25
+
26
+ var _default = NoResults;
27
+ exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -81,13 +81,23 @@ export const messages = defineMessages({
81
81
  description: 'Describes type of items shown in the list for screen-reader users'
82
82
  },
83
83
  cancelButton: {
84
- id: 'fabric.linkPicker.cancel.button',
84
+ id: 'fabric.linkPicker.button.cancel',
85
85
  defaultMessage: 'Cancel',
86
86
  description: 'Button to cancel and dismiss the link picker'
87
87
  },
88
88
  insertButton: {
89
- id: 'fabric.linkPicker.cancel.insert',
89
+ id: 'fabric.linkPicker.button.insert',
90
90
  defaultMessage: 'Insert',
91
91
  description: 'Button to insert searched or selected link'
92
+ },
93
+ noResults: {
94
+ id: 'fabric.linkPicker.search.noResults.heading',
95
+ defaultMessage: 'We couldn’t find anything matching your search.',
96
+ description: 'Heading message shown when a search has no results'
97
+ },
98
+ noResultsDescription: {
99
+ id: 'fabric.linkPicker.search.noResults.description',
100
+ defaultMessage: 'Try again with a different term.',
101
+ description: 'Describes possible action when a search returns no results'
92
102
  }
93
103
  });
@@ -16,6 +16,7 @@ import Button, { ButtonGroup } from '@atlaskit/button';
16
16
  import { FormFooter } from '@atlaskit/form';
17
17
  import EditorSearchIcon from '@atlaskit/icon/glyph/editor/search';
18
18
  import VisuallyHidden from '@atlaskit/visually-hidden';
19
+ import LinkSearchNoResults from './link-search-no-results';
19
20
  export const RECENT_SEARCH_LIST_SIZE = 5;
20
21
 
21
22
  class LinkPicker extends PureComponent {
@@ -386,6 +387,7 @@ class LinkPicker extends PureComponent {
386
387
  size: "medium",
387
388
  label: ''
388
389
  }));
390
+ const noResults = activePlugin && !isLoading && !items.length && !isSafeUrl(url);
389
391
  return jsx("div", {
390
392
  "data-testid": "link-picker",
391
393
  className: "recent-list",
@@ -457,6 +459,10 @@ class LinkPicker extends PureComponent {
457
459
  onSelect: this.handleSelected,
458
460
  onMouseEnter: this.handleMouseEnterResultItem,
459
461
  onMouseLeave: this.handleMouseLeaveResultItem
462
+ }), noResults && jsx(LinkSearchNoResults, {
463
+ testId: "link-search-no-results",
464
+ header: formatMessage(messages.noResults),
465
+ description: formatMessage(messages.noResultsDescription)
460
466
  }), jsx(FormFooter, {
461
467
  align: "end"
462
468
  }, jsx(ButtonGroup, null, jsx(Button, {
@@ -0,0 +1,12 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import EmptyState from '@atlaskit/empty-state';
4
+ import noResultsImg from './no-results.svg';
5
+
6
+ const NoResults = props => /*#__PURE__*/React.createElement(EmptyState, _extends({}, props, {
7
+ imageUrl: noResultsImg,
8
+ maxImageWidth: 130,
9
+ maxImageHeight: 130
10
+ }));
11
+
12
+ export default NoResults;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -81,13 +81,23 @@ export var messages = defineMessages({
81
81
  description: 'Describes type of items shown in the list for screen-reader users'
82
82
  },
83
83
  cancelButton: {
84
- id: 'fabric.linkPicker.cancel.button',
84
+ id: 'fabric.linkPicker.button.cancel',
85
85
  defaultMessage: 'Cancel',
86
86
  description: 'Button to cancel and dismiss the link picker'
87
87
  },
88
88
  insertButton: {
89
- id: 'fabric.linkPicker.cancel.insert',
89
+ id: 'fabric.linkPicker.button.insert',
90
90
  defaultMessage: 'Insert',
91
91
  description: 'Button to insert searched or selected link'
92
+ },
93
+ noResults: {
94
+ id: 'fabric.linkPicker.search.noResults.heading',
95
+ defaultMessage: 'We couldn’t find anything matching your search.',
96
+ description: 'Heading message shown when a search has no results'
97
+ },
98
+ noResultsDescription: {
99
+ id: 'fabric.linkPicker.search.noResults.description',
100
+ defaultMessage: 'Try again with a different term.',
101
+ description: 'Describes possible action when a search returns no results'
92
102
  }
93
103
  });
@@ -1,4 +1,3 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
@@ -12,6 +11,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
12
11
 
13
12
  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; }
14
13
 
14
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
15
+
15
16
  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); }; }
16
17
 
17
18
  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; } }
@@ -32,6 +33,7 @@ import Button, { ButtonGroup } from '@atlaskit/button';
32
33
  import { FormFooter } from '@atlaskit/form';
33
34
  import EditorSearchIcon from '@atlaskit/icon/glyph/editor/search';
34
35
  import VisuallyHidden from '@atlaskit/visually-hidden';
36
+ import LinkSearchNoResults from './link-search-no-results';
35
37
  export var RECENT_SEARCH_LIST_SIZE = 5;
36
38
 
37
39
  var LinkPicker = /*#__PURE__*/function (_PureComponent) {
@@ -473,6 +475,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
473
475
  size: "medium",
474
476
  label: ''
475
477
  }));
478
+ var noResults = activePlugin && !isLoading && !items.length && !isSafeUrl(url);
476
479
  return jsx("div", {
477
480
  "data-testid": "link-picker",
478
481
  className: "recent-list",
@@ -544,6 +547,10 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
544
547
  onSelect: this.handleSelected,
545
548
  onMouseEnter: this.handleMouseEnterResultItem,
546
549
  onMouseLeave: this.handleMouseLeaveResultItem
550
+ }), noResults && jsx(LinkSearchNoResults, {
551
+ testId: "link-search-no-results",
552
+ header: formatMessage(messages.noResults),
553
+ description: formatMessage(messages.noResultsDescription)
547
554
  }), jsx(FormFooter, {
548
555
  align: "end"
549
556
  }, jsx(ButtonGroup, null, jsx(Button, {
@@ -0,0 +1,14 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import EmptyState from '@atlaskit/empty-state';
4
+ import noResultsImg from './no-results.svg';
5
+
6
+ var NoResults = function NoResults(props) {
7
+ return /*#__PURE__*/React.createElement(EmptyState, _extends({}, props, {
8
+ imageUrl: noResultsImg,
9
+ maxImageWidth: 130,
10
+ maxImageHeight: 130
11
+ }));
12
+ };
13
+
14
+ export default NoResults;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -89,4 +89,14 @@ export declare const messages: {
89
89
  defaultMessage: string;
90
90
  description: string;
91
91
  };
92
+ noResults: {
93
+ id: string;
94
+ defaultMessage: string;
95
+ description: string;
96
+ };
97
+ noResultsDescription: {
98
+ id: string;
99
+ defaultMessage: string;
100
+ description: string;
101
+ };
92
102
  };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { EmptyStateProps } from '@atlaskit/empty-state';
3
+ declare const NoResults: (props: EmptyStateProps) => JSX.Element;
4
+ export default NoResults;
@@ -1,5 +1,3 @@
1
- // import sub from 'date-fns/sub';
2
-
3
1
  export interface MockDataV3 {
4
2
  ACTIVITIES_DATA: {
5
3
  data: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Standalone link picker",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
@@ -27,6 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@atlaskit/button": "^16.2.0",
30
+ "@atlaskit/empty-state": "^7.3.0",
30
31
  "@atlaskit/form": "^8.5.1",
31
32
  "@atlaskit/icon": "^21.10.0",
32
33
  "@atlaskit/spinner": "^15.1.0",
@@ -48,14 +49,13 @@
48
49
  "@atlaskit/activity-provider": "^2.3.2",
49
50
  "@atlaskit/button": "^16.3.0",
50
51
  "@atlaskit/docs": "*",
51
- "@atlaskit/editor-test-helpers": "^17.0.0",
52
- "@atlaskit/media-test-helpers": "^30.0.0",
52
+ "@atlaskit/link-test-helpers": "^1.1.0",
53
53
  "@atlaskit/popup": "^1.3.5",
54
54
  "@atlaskit/ssr": "*",
55
55
  "@atlaskit/visual-regression": "*",
56
56
  "@atlaskit/webdriver-runner": "*",
57
57
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
58
- "@atlassian/link-picker-atlassian-plugin": "^10.0.0",
58
+ "@atlassian/link-picker-atlassian-plugin": "^11.0.0",
59
59
  "@atlassian/search-provider": "^2.3.0",
60
60
  "@testing-library/dom": "^7.7.3",
61
61
  "@testing-library/react": "^8.0.1",
package/report.api.md ADDED
@@ -0,0 +1,65 @@
1
+ ## API Report File for "@atlaskit/link-picker"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+ /// <reference types="react" />
7
+
8
+ import { MessageDescriptor } from 'react-intl-next';
9
+ import { default as React_2 } from 'react';
10
+ import { WithIntlProps } from 'react-intl-next';
11
+ import { WrappedComponentProps } from 'react-intl-next';
12
+
13
+ // @public (undocumented)
14
+ export type LinkInputType = 'manual' | 'typeAhead';
15
+
16
+ // @public (undocumented)
17
+ export const LinkPicker: React_2.FC<
18
+ WithIntlProps<WrappedComponentProps<'intl'> & LinkPickerProps>
19
+ > & {
20
+ WrappedComponent: React_2.ComponentType<
21
+ WrappedComponentProps<'intl'> & LinkPickerProps
22
+ >;
23
+ };
24
+
25
+ // @public (undocumented)
26
+ export interface LinkPickerPlugin {
27
+ // (undocumented)
28
+ resolve: (
29
+ state: LinkPickerState,
30
+ ) => Promise<ResolveResult> | AsyncGenerator<ResolveResult, ResolveResult>;
31
+ }
32
+
33
+ // @public (undocumented)
34
+ export interface LinkPickerProps {
35
+ displayText?: string | null;
36
+ onCancel: () => void;
37
+ onSubmit: (arg: OnSubmitParameter) => void;
38
+ plugins?: LinkPickerPlugin[];
39
+ url?: string;
40
+ }
41
+
42
+ // @public (undocumented)
43
+ export interface LinkPickerState {
44
+ query: string;
45
+ }
46
+
47
+ // @public (undocumented)
48
+ export interface LinkSearchListItemData {
49
+ container?: string;
50
+ icon:
51
+ | string
52
+ | React.ComponentType<{
53
+ alt: string;
54
+ }>;
55
+ iconAlt: string | MessageDescriptor;
56
+ lastUpdatedDate?: Date;
57
+ lastViewedDate?: Date;
58
+ name: string;
59
+ objectId: string;
60
+ prefetch?: boolean;
61
+ url: string;
62
+ }
63
+
64
+ // (No @packageDocumentation comment for this package)
65
+ ```