@atlaskit/link-picker 0.7.0 → 0.9.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,23 @@
1
1
  # @atlaskit/link-picker
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`c1c010c8ada`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c1c010c8ada) - Remove required container param
8
+
9
+ ## 0.8.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`eef8c2da75b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eef8c2da75b) - [ux] Remove link-picker background color as it conflicts with floatingToobar borders
14
+
15
+ ## 0.8.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`1e371fd8d23`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1e371fd8d23) - Updates link picker to support array of plugins. Removes intl prop from LinkPickerProps type.
20
+
3
21
  ## 0.7.0
4
22
 
5
23
  ### Minor Changes
@@ -26,7 +26,7 @@ var _theme = require("@atlaskit/theme");
26
26
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
27
27
 
28
28
  var LINK_PICKER_WIDTH_IN_PX = 342;
29
- var recentListStyles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: ", "px;\n background: ", ";\n"])), LINK_PICKER_WIDTH_IN_PX, (0, _tokens.token)('elevation.surface.overlay', _colors.N0));
29
+ var recentListStyles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: ", "px;\n"])), LINK_PICKER_WIDTH_IN_PX);
30
30
  exports.recentListStyles = recentListStyles;
31
31
 
32
32
  var Container = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n padding: ", "px;\n width: 100%;\n overflow: hidden;\n line-height: initial;\n box-sizing: border-box;\n"])), (0, _constants.gridSize)() * 2);
@@ -52,7 +52,7 @@ var LinkSearchListItem = function LinkSearchListItem(_ref) {
52
52
  }, (0, _core.jsx)(ListItemIcon, {
53
53
  item: item,
54
54
  intl: intl
55
- }), (0, _core.jsx)(_styles.ItemNameWrapper, null, (0, _core.jsx)(_styles.ListItemName, null, item.name), (0, _core.jsx)(_styles.ListItemContext, null, item.container, (0, _core.jsx)(ItemTimeStamp, {
55
+ }), (0, _core.jsx)(_styles.ItemNameWrapper, null, (0, _core.jsx)(_styles.ListItemName, null, item.name), (0, _core.jsx)(_styles.ListItemContext, null, item.container && (0, _core.jsx)(_react.Fragment, null, item.container, "\xA0 \u2022"), (0, _core.jsx)(ItemTimeStamp, {
56
56
  date: (0, _transformTimeStamp.transformTimeStamp)(intl, item.lastViewedDate, item.lastUpdatedDate)
57
57
  }))));
58
58
  };
@@ -68,7 +68,7 @@ var ItemTimeStamp = function ItemTimeStamp(props) {
68
68
  return null;
69
69
  }
70
70
 
71
- return (0, _core.jsx)(_react.Fragment, null, "\xA0 \u2022", (0, _core.jsx)("span", {
71
+ return (0, _core.jsx)(_react.Fragment, null, (0, _core.jsx)("span", {
72
72
  className: "link-search-timestamp",
73
73
  "data-test-id": "link-search-timestamp"
74
74
  }, "\xA0 ", date.pageAction, " ", date.dateString, " ", date.timeSince || ''));
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.RECENT_SEARCH_LIST_SIZE = exports.LinkPickerWithIntl = exports.LinkPicker = void 0;
10
+ exports.RECENT_SEARCH_LIST_SIZE = exports.LinkPickerWithIntl = void 0;
11
11
 
12
12
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
13
 
@@ -155,7 +155,8 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
155
155
  lastUpdatedDate = _items$selectedIndex.lastUpdatedDate,
156
156
  lastViewedDate = _items$selectedIndex.lastViewedDate;
157
157
  var date = (0, _transformTimeStamp.transformTimeStamp)(intl, lastViewedDate, lastUpdatedDate);
158
- return "".concat(name, ", ").concat(container, ", ").concat(date === null || date === void 0 ? void 0 : date.pageAction, " ").concat(date === null || date === void 0 ? void 0 : date.dateString, " ").concat((date === null || date === void 0 ? void 0 : date.timeSince) || '');
158
+ var formattedDate = [date === null || date === void 0 ? void 0 : date.pageAction, date === null || date === void 0 ? void 0 : date.dateString, date === null || date === void 0 ? void 0 : date.timeSince].filter(Boolean).join(' ');
159
+ return [name, container, formattedDate].filter(Boolean).join(', ');
159
160
  }
160
161
  });
161
162
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isUrlPopulatedWithSelectedItem", function () {
@@ -342,7 +343,7 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
342
343
  }, {
343
344
  key: "getActivePlugin",
344
345
  value: function getActivePlugin() {
345
- if (!this.props.plugins) {
346
+ if (!this.props.plugins || this.props.plugins.length === 0) {
346
347
  return null;
347
348
  }
348
349
 
@@ -561,8 +562,6 @@ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
561
562
  return LinkPicker;
562
563
  }(_react.PureComponent);
563
564
 
564
- exports.LinkPicker = LinkPicker;
565
-
566
565
  function findIndex(array, predicate) {
567
566
  var index = -1;
568
567
  array.some(function (item, i) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import styled from 'styled-components';
2
2
  import { token } from '@atlaskit/tokens';
3
3
  import { css } from '@emotion/core';
4
- import { N500, N0, B50, N300, N800, N20, B400 } from '@atlaskit/theme/colors';
4
+ import { N500, B50, N300, N800, N20, B400 } from '@atlaskit/theme/colors';
5
5
  import { gridSize } from '@atlaskit/theme/constants';
6
6
  import { relativeFontSizeToBase16 } from './utils'; // AFP-2532 TODO: Fix automatic suppressions below
7
7
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
@@ -10,7 +10,6 @@ import { fontSizeSmall, fontSize, typography } from '@atlaskit/theme';
10
10
  const LINK_PICKER_WIDTH_IN_PX = 342;
11
11
  export const recentListStyles = css`
12
12
  width: ${LINK_PICKER_WIDTH_IN_PX}px;
13
- background: ${token('elevation.surface.overlay', N0)};
14
13
  `;
15
14
  export const Container = styled.div`
16
15
  padding: ${gridSize() * 2}px;
@@ -35,7 +35,7 @@ const LinkSearchListItem = ({
35
35
  }, jsx(ListItemIcon, {
36
36
  item: item,
37
37
  intl: intl
38
- }), jsx(ItemNameWrapper, null, jsx(ListItemName, null, item.name), jsx(ListItemContext, null, item.container, jsx(ItemTimeStamp, {
38
+ }), jsx(ItemNameWrapper, null, jsx(ListItemName, null, item.name), jsx(ListItemContext, null, item.container && jsx(Fragment, null, item.container, "\xA0 \u2022"), jsx(ItemTimeStamp, {
39
39
  date: transformTimeStamp(intl, item.lastViewedDate, item.lastUpdatedDate)
40
40
  }))));
41
41
  };
@@ -51,7 +51,7 @@ const ItemTimeStamp = props => {
51
51
  return null;
52
52
  }
53
53
 
54
- return jsx(Fragment, null, "\xA0 \u2022", jsx("span", {
54
+ return jsx(Fragment, null, jsx("span", {
55
55
  className: "link-search-timestamp",
56
56
  "data-test-id": "link-search-timestamp"
57
57
  }, "\xA0 ", date.pageAction, " ", date.dateString, " ", date.timeSince || ''));
@@ -17,7 +17,8 @@ import { FormFooter } from '@atlaskit/form';
17
17
  import EditorSearchIcon from '@atlaskit/icon/glyph/editor/search';
18
18
  import VisuallyHidden from '@atlaskit/visually-hidden';
19
19
  export const RECENT_SEARCH_LIST_SIZE = 5;
20
- export class LinkPicker extends PureComponent {
20
+
21
+ class LinkPicker extends PureComponent {
21
22
  constructor(props) {
22
23
  super(props);
23
24
 
@@ -83,7 +84,8 @@ export class LinkPicker extends PureComponent {
83
84
  lastViewedDate
84
85
  } = items[selectedIndex];
85
86
  const date = transformTimeStamp(intl, lastViewedDate, lastUpdatedDate);
86
- return `${name}, ${container}, ${date === null || date === void 0 ? void 0 : date.pageAction} ${date === null || date === void 0 ? void 0 : date.dateString} ${(date === null || date === void 0 ? void 0 : date.timeSince) || ''}`;
87
+ const formattedDate = [date === null || date === void 0 ? void 0 : date.pageAction, date === null || date === void 0 ? void 0 : date.dateString, date === null || date === void 0 ? void 0 : date.timeSince].filter(Boolean).join(' ');
88
+ return [name, container, formattedDate].filter(Boolean).join(', ');
87
89
  }
88
90
  });
89
91
 
@@ -288,7 +290,7 @@ export class LinkPicker extends PureComponent {
288
290
  }
289
291
 
290
292
  getActivePlugin() {
291
- if (!this.props.plugins) {
293
+ if (!this.props.plugins || this.props.plugins.length === 0) {
292
294
  return null;
293
295
  }
294
296
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -5,14 +5,14 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _temp
5
5
  import styled from 'styled-components';
6
6
  import { token } from '@atlaskit/tokens';
7
7
  import { css } from '@emotion/core';
8
- import { N500, N0, B50, N300, N800, N20, B400 } from '@atlaskit/theme/colors';
8
+ import { N500, B50, N300, N800, N20, B400 } from '@atlaskit/theme/colors';
9
9
  import { gridSize } from '@atlaskit/theme/constants';
10
10
  import { relativeFontSizeToBase16 } from './utils'; // AFP-2532 TODO: Fix automatic suppressions below
11
11
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
12
12
 
13
13
  import { fontSizeSmall, fontSize, typography } from '@atlaskit/theme';
14
14
  var LINK_PICKER_WIDTH_IN_PX = 342;
15
- export var recentListStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n background: ", ";\n"])), LINK_PICKER_WIDTH_IN_PX, token('elevation.surface.overlay', N0));
15
+ export var recentListStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: ", "px;\n"])), LINK_PICKER_WIDTH_IN_PX);
16
16
  export var Container = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: ", "px;\n width: 100%;\n overflow: hidden;\n line-height: initial;\n box-sizing: border-box;\n"])), gridSize() * 2);
17
17
  export var ClearText = styled.button(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 0;\n margin-right: ", "px;\n color: ", ";\n background: transparent;\n border: none;\n cursor: pointer;\n"])), gridSize() / 2, token('color.icon.subtle', N500));
18
18
  export var FieldWrapper = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n margin-bottom: ", "px;\n"])), gridSize() * 2);
@@ -41,7 +41,7 @@ var LinkSearchListItem = function LinkSearchListItem(_ref) {
41
41
  }, jsx(ListItemIcon, {
42
42
  item: item,
43
43
  intl: intl
44
- }), jsx(ItemNameWrapper, null, jsx(ListItemName, null, item.name), jsx(ListItemContext, null, item.container, jsx(ItemTimeStamp, {
44
+ }), jsx(ItemNameWrapper, null, jsx(ListItemName, null, item.name), jsx(ListItemContext, null, item.container && jsx(Fragment, null, item.container, "\xA0 \u2022"), jsx(ItemTimeStamp, {
45
45
  date: transformTimeStamp(intl, item.lastViewedDate, item.lastUpdatedDate)
46
46
  }))));
47
47
  };
@@ -55,7 +55,7 @@ var ItemTimeStamp = function ItemTimeStamp(props) {
55
55
  return null;
56
56
  }
57
57
 
58
- return jsx(Fragment, null, "\xA0 \u2022", jsx("span", {
58
+ return jsx(Fragment, null, jsx("span", {
59
59
  className: "link-search-timestamp",
60
60
  "data-test-id": "link-search-timestamp"
61
61
  }, "\xA0 ", date.pageAction, " ", date.dateString, " ", date.timeSince || ''));
@@ -33,7 +33,8 @@ import { FormFooter } from '@atlaskit/form';
33
33
  import EditorSearchIcon from '@atlaskit/icon/glyph/editor/search';
34
34
  import VisuallyHidden from '@atlaskit/visually-hidden';
35
35
  export var RECENT_SEARCH_LIST_SIZE = 5;
36
- export var LinkPicker = /*#__PURE__*/function (_PureComponent) {
36
+
37
+ var LinkPicker = /*#__PURE__*/function (_PureComponent) {
37
38
  _inherits(LinkPicker, _PureComponent);
38
39
 
39
40
  var _super = _createSuper(LinkPicker);
@@ -122,7 +123,8 @@ export var LinkPicker = /*#__PURE__*/function (_PureComponent) {
122
123
  lastUpdatedDate = _items$selectedIndex.lastUpdatedDate,
123
124
  lastViewedDate = _items$selectedIndex.lastViewedDate;
124
125
  var date = transformTimeStamp(intl, lastViewedDate, lastUpdatedDate);
125
- return "".concat(name, ", ").concat(container, ", ").concat(date === null || date === void 0 ? void 0 : date.pageAction, " ").concat(date === null || date === void 0 ? void 0 : date.dateString, " ").concat((date === null || date === void 0 ? void 0 : date.timeSince) || '');
126
+ var formattedDate = [date === null || date === void 0 ? void 0 : date.pageAction, date === null || date === void 0 ? void 0 : date.dateString, date === null || date === void 0 ? void 0 : date.timeSince].filter(Boolean).join(' ');
127
+ return [name, container, formattedDate].filter(Boolean).join(', ');
126
128
  }
127
129
  });
128
130
 
@@ -319,7 +321,7 @@ export var LinkPicker = /*#__PURE__*/function (_PureComponent) {
319
321
  }, {
320
322
  key: "getActivePlugin",
321
323
  value: function getActivePlugin() {
322
- if (!this.props.plugins) {
324
+ if (!this.props.plugins || this.props.plugins.length === 0) {
323
325
  return null;
324
326
  }
325
327
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -8,14 +8,14 @@ export interface LinkSearchListItemData {
8
8
  name: string;
9
9
  /** URL of the resource being linked to */
10
10
  url: string;
11
- /** Context to display in link result */
12
- container: string;
13
11
  /** Icon to display in link result */
14
12
  icon: string | React.ComponentType<{
15
13
  alt: string;
16
14
  }>;
17
15
  /** Alt text describing the icon */
18
16
  iconAlt: string | MessageDescriptor;
17
+ /** Context to display in link result */
18
+ container?: string;
19
19
  /** Optional last view date to display in link result */
20
20
  lastViewedDate?: Date;
21
21
  /** Optional last updated date to display in link result */
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import React, { PureComponent } from 'react';
2
+ import React from 'react';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
4
  import { LinkSearchListItemData, LinkInputType, LinkPickerPlugin } from '../types';
5
5
  export declare const RECENT_SEARCH_LIST_SIZE = 5;
@@ -24,7 +24,7 @@ interface OnSubmitParameter {
24
24
  */
25
25
  rawUrl?: string;
26
26
  }
27
- interface BaseProps {
27
+ export interface LinkPickerProps {
28
28
  /** Callback to fire on form submission. */
29
29
  onSubmit: (arg: OnSubmitParameter) => void;
30
30
  /** Callback to fire when the cancel button is clicked. */
@@ -34,9 +34,8 @@ interface BaseProps {
34
34
  /** The desired text to be displayed alternatively to the title of the linked resource for editing. */
35
35
  displayText?: string | null;
36
36
  /** Plugins that provide link suggestions / search capabilities. */
37
- plugins?: [LinkPickerPlugin];
37
+ plugins?: LinkPickerPlugin[];
38
38
  }
39
- export declare type LinkPickerProps = WrappedComponentProps & BaseProps;
40
39
  export interface State {
41
40
  items: LinkSearchListItemData[];
42
41
  selectedIndex: number;
@@ -46,34 +45,7 @@ export interface State {
46
45
  displayText: string;
47
46
  invalidUrl: string | null;
48
47
  }
49
- export declare class LinkPicker extends PureComponent<LinkPickerProps, State> {
50
- private wrapperRef;
51
- private handleClearUrl;
52
- private handleClearDisplayText;
53
- private queryVersion;
54
- constructor(props: LinkPickerProps);
55
- componentDidMount(): void;
56
- private loadInitialLinkSearchResult;
57
- private getActivePlugin;
58
- /**
59
- * Interface between link picker and plugins to update results
60
- */
61
- private updateResults;
62
- private updateInput;
63
- private createClearHandler;
64
- private getScreenReaderText;
65
- render(): JSX.Element;
66
- private isUrlPopulatedWithSelectedItem;
67
- private handleSelected;
68
- private handleInsert;
69
- private handleMouseEnterResultItem;
70
- private handleMouseLeaveResultItem;
71
- private handleSubmit;
72
- private handleKeyDown;
73
- private handleCancel;
74
- private updateTextInput;
75
- }
76
- export declare const LinkPickerWithIntl: React.FC<import("react-intl-next").WithIntlProps<LinkPickerProps>> & {
77
- WrappedComponent: React.ComponentType<LinkPickerProps>;
48
+ export declare const LinkPickerWithIntl: React.FC<import("react-intl-next").WithIntlProps<WrappedComponentProps<"intl"> & LinkPickerProps>> & {
49
+ WrappedComponent: React.ComponentType<WrappedComponentProps<"intl"> & LinkPickerProps>;
78
50
  };
79
51
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Standalone link picker",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/visual-regression": "*",
57
57
  "@atlaskit/webdriver-runner": "*",
58
58
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
59
- "@atlassian/link-picker-atlassian-plugin": "^5.0.0",
59
+ "@atlassian/link-picker-atlassian-plugin": "^7.0.0",
60
60
  "@atlassian/search-provider": "^2.3.0",
61
61
  "@testing-library/react": "^8.0.1",
62
62
  "enzyme": "^3.10.0",