@atlaskit/link-picker 1.8.3 → 1.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/controllers/use-fix-height/index.js +27 -0
  3. package/dist/cjs/services/use-plugins/index.js +48 -90
  4. package/dist/cjs/services/use-plugins/reducer.js +64 -0
  5. package/dist/cjs/services/use-plugins/utils.js +134 -0
  6. package/dist/cjs/ui/index.js +2 -1
  7. package/dist/cjs/ui/link-picker/form-footer/index.js +76 -0
  8. package/dist/cjs/ui/link-picker/form-footer/styled.js +17 -0
  9. package/dist/cjs/ui/link-picker/index.js +35 -76
  10. package/dist/cjs/ui/link-picker/link-search-error/index.js +47 -6
  11. package/dist/cjs/ui/link-picker/link-search-list/index.js +89 -20
  12. package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/index.js +54 -0
  13. package/dist/cjs/ui/link-picker/{link-search-no-results → link-search-list/link-search-no-results}/no-results-svg/index.js +0 -0
  14. package/dist/cjs/ui/link-picker/{link-search-no-results → link-search-list/link-search-no-results}/no-results-svg/styled.js +0 -0
  15. package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/styled.js +17 -0
  16. package/dist/cjs/ui/link-picker/link-search-list/styled.js +13 -6
  17. package/dist/cjs/ui/link-picker/messages.js +0 -50
  18. package/dist/cjs/ui/link-picker/styled.js +16 -11
  19. package/dist/cjs/ui/link-picker/text-input/styled.js +1 -1
  20. package/dist/cjs/version.json +1 -1
  21. package/dist/es2019/controllers/use-fix-height/index.js +19 -0
  22. package/dist/es2019/services/use-plugins/index.js +35 -57
  23. package/dist/es2019/services/use-plugins/reducer.js +37 -0
  24. package/dist/es2019/services/use-plugins/utils.js +59 -0
  25. package/dist/es2019/ui/index.js +1 -1
  26. package/dist/es2019/ui/link-picker/form-footer/index.js +51 -0
  27. package/dist/es2019/ui/link-picker/form-footer/styled.js +5 -0
  28. package/dist/es2019/ui/link-picker/index.js +30 -68
  29. package/dist/es2019/ui/link-picker/link-search-error/index.js +40 -4
  30. package/dist/es2019/ui/link-picker/link-search-list/index.js +60 -14
  31. package/dist/es2019/ui/link-picker/link-search-list/link-search-no-results/index.js +35 -0
  32. package/dist/es2019/ui/link-picker/{link-search-no-results → link-search-list/link-search-no-results}/no-results-svg/index.js +0 -0
  33. package/dist/es2019/ui/link-picker/{link-search-no-results → link-search-list/link-search-no-results}/no-results-svg/styled.js +0 -0
  34. package/dist/es2019/ui/link-picker/link-search-list/link-search-no-results/styled.js +6 -0
  35. package/dist/es2019/ui/link-picker/link-search-list/styled.js +23 -2
  36. package/dist/es2019/ui/link-picker/messages.js +0 -50
  37. package/dist/es2019/ui/link-picker/styled.js +20 -15
  38. package/dist/es2019/ui/link-picker/text-input/styled.js +3 -1
  39. package/dist/es2019/version.json +1 -1
  40. package/dist/esm/controllers/use-fix-height/index.js +19 -0
  41. package/dist/esm/services/use-plugins/index.js +49 -94
  42. package/dist/esm/services/use-plugins/reducer.js +43 -0
  43. package/dist/esm/services/use-plugins/utils.js +111 -0
  44. package/dist/esm/ui/index.js +1 -1
  45. package/dist/esm/ui/link-picker/form-footer/index.js +53 -0
  46. package/dist/esm/ui/link-picker/form-footer/styled.js +6 -0
  47. package/dist/esm/ui/link-picker/index.js +31 -73
  48. package/dist/esm/ui/link-picker/link-search-error/index.js +41 -5
  49. package/dist/esm/ui/link-picker/link-search-list/index.js +67 -13
  50. package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/index.js +37 -0
  51. package/dist/esm/ui/link-picker/{link-search-no-results → link-search-list/link-search-no-results}/no-results-svg/index.js +0 -0
  52. package/dist/esm/ui/link-picker/{link-search-no-results → link-search-list/link-search-no-results}/no-results-svg/styled.js +0 -0
  53. package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/styled.js +6 -0
  54. package/dist/esm/ui/link-picker/link-search-list/styled.js +11 -5
  55. package/dist/esm/ui/link-picker/messages.js +0 -50
  56. package/dist/esm/ui/link-picker/styled.js +14 -11
  57. package/dist/esm/ui/link-picker/text-input/styled.js +1 -1
  58. package/dist/esm/version.json +1 -1
  59. package/dist/types/controllers/use-fix-height/index.d.ts +8 -0
  60. package/dist/types/services/use-plugins/reducer.d.ts +30 -0
  61. package/dist/types/services/use-plugins/utils.d.ts +18 -0
  62. package/dist/types/ui/index.d.ts +5 -0
  63. package/dist/types/ui/link-picker/form-footer/index.d.ts +13 -0
  64. package/dist/types/ui/link-picker/form-footer/styled.d.ts +1 -0
  65. package/dist/types/ui/link-picker/index.d.ts +21 -18
  66. package/dist/types/ui/link-picker/link-search-error/index.d.ts +19 -3
  67. package/dist/types/ui/link-picker/link-search-list/index.d.ts +30 -5
  68. package/dist/types/ui/link-picker/link-search-list/link-search-no-results/index.d.ts +19 -0
  69. package/dist/types/ui/link-picker/{link-search-no-results → link-search-list/link-search-no-results}/no-results-svg/index.d.ts +0 -0
  70. package/dist/types/ui/link-picker/{link-search-no-results → link-search-list/link-search-no-results}/no-results-svg/styled.d.ts +0 -0
  71. package/dist/types/ui/link-picker/link-search-list/link-search-no-results/styled.d.ts +1 -0
  72. package/dist/types/ui/link-picker/link-search-list/styled.d.ts +1 -0
  73. package/dist/types/ui/link-picker/messages.d.ts +0 -50
  74. package/dist/types/ui/link-picker/styled.d.ts +5 -1
  75. package/package.json +15 -14
  76. package/report.api.md +8 -2
  77. package/dist/cjs/ui/link-picker/link-search-no-results/index.js +0 -27
  78. package/dist/es2019/ui/link-picker/link-search-no-results/index.js +0 -10
  79. package/dist/esm/ui/link-picker/link-search-no-results/index.js +0 -14
  80. package/dist/types/ui/link-picker/link-search-no-results/index.d.ts +0 -4
@@ -0,0 +1,35 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import EmptyState from '@atlaskit/empty-state';
4
+ import { useIntl, defineMessages } from 'react-intl-next';
5
+ import NoResultsSVG from './no-results-svg';
6
+ import { emptyStateWrapperStyles } from './styled';
7
+ export const messages = defineMessages({
8
+ noResults: {
9
+ id: 'fabric.linkPicker.search.noResults.heading',
10
+ defaultMessage: 'We couldn’t find anything matching your search.',
11
+ description: 'Heading message shown when a search has no results'
12
+ },
13
+ noResultsDescription: {
14
+ id: 'fabric.linkPicker.search.noResults.description',
15
+ defaultMessage: 'Try again with a different term.',
16
+ description: 'Describes possible action when a search returns no results'
17
+ }
18
+ });
19
+ export const testIds = {
20
+ emptyResultPage: 'link-search-no-results'
21
+ };
22
+
23
+ const NoResults = () => {
24
+ const intl = useIntl();
25
+ return jsx("div", {
26
+ css: emptyStateWrapperStyles
27
+ }, jsx(EmptyState, {
28
+ testId: testIds.emptyResultPage,
29
+ header: intl.formatMessage(messages.noResults),
30
+ description: intl.formatMessage(messages.noResultsDescription),
31
+ renderImage: () => jsx(NoResultsSVG, null)
32
+ }));
33
+ };
34
+
35
+ export default NoResults;
@@ -0,0 +1,6 @@
1
+ import { css } from '@emotion/react';
2
+ export const emptyStateWrapperStyles = css`
3
+ & p {
4
+ margin: 0;
5
+ }
6
+ `;
@@ -1,13 +1,34 @@
1
- import { css } from '@emotion/react';
1
+ import { css } from '@emotion/react'; // AFP-2532 TODO: Fix automatic suppressions below
2
+ // eslint-disable-next-line @atlassian/tangerine/import/entry-points
3
+
4
+ import { typography } from '@atlaskit/theme';
5
+ import { gridSize as getGridSize } from '@atlaskit/theme/constants';
6
+ const gridSize = getGridSize();
2
7
  export const listContainerStyles = css`
3
8
  padding-top: 0;
9
+ min-height: 80px;
10
+ margin-top: ${gridSize * 2}px;
11
+ margin-bottom: ${gridSize * 2}px;
12
+ flex-grow: 1;
13
+ display: flex;
14
+ flex-direction: column;
4
15
  `;
5
16
  export const spinnerContainerStyles = css`
6
17
  text-align: center;
7
18
  min-height: 80px;
8
- margin-top: 30px;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ flex-grow: 1;
9
23
  `;
10
24
  export const listStyles = css`
11
25
  padding: 0;
26
+ margin: 0;
12
27
  list-style: none;
28
+ `;
29
+ export const listTitleStyles = css`
30
+ ${typography.h100()}
31
+ text-transform: uppercase;
32
+ margin-top: 0;
33
+ margin-bottom: ${gridSize / 2}px;
13
34
  `;
@@ -45,11 +45,6 @@ export const messages = defineMessages({
45
45
  defaultMessage: 'Suggestions will appear below as you type into the field',
46
46
  description: 'Describes what the search field does for screen reader users.'
47
47
  },
48
- searchLinkResults: {
49
- id: 'fabric.linkPicker.hyperlink.searchLinkResults',
50
- defaultMessage: '{count, plural, =0 {no results} one {# result} other {# results}} found',
51
- description: 'Announce search results for screen-reader users.'
52
- },
53
48
  linkAriaLabel: {
54
49
  id: 'fabric.linkPicker.hyperlink.linkAriaLabel',
55
50
  defaultMessage: 'Link label',
@@ -69,50 +64,5 @@ export const messages = defineMessages({
69
64
  id: 'fabric.linkPicker.time.ago',
70
65
  defaultMessage: 'ago',
71
66
  description: 'Some time ago'
72
- },
73
- titleRecentlyViewed: {
74
- id: 'fabric.linkPicker.listTitle.recentlyViewed',
75
- defaultMessage: 'Recently Viewed',
76
- description: 'Describes type of items shown in the list for screen-reader users'
77
- },
78
- titleResults: {
79
- id: 'fabric.linkPicker.listTitle.results',
80
- defaultMessage: 'Results',
81
- description: 'Describes type of items shown in the list for screen-reader users'
82
- },
83
- cancelButton: {
84
- id: 'fabric.linkPicker.button.cancel',
85
- defaultMessage: 'Cancel',
86
- description: 'Button to cancel and dismiss the link picker'
87
- },
88
- insertButton: {
89
- id: 'fabric.linkPicker.button.insert',
90
- defaultMessage: 'Insert',
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'
102
- },
103
- saveButton: {
104
- id: 'fabric.linkPicker.button.save',
105
- defaultMessage: 'Save',
106
- description: 'Button to save edited link'
107
- },
108
- searchErrorHeader: {
109
- id: 'fabric.linkPicker.search.error.heading',
110
- defaultMessage: 'We’re having trouble loading data.',
111
- description: 'Heading message shown when a search throws an error'
112
- },
113
- searchErrorDescription: {
114
- id: 'fabric.linkPicker.search.error.description',
115
- defaultMessage: 'Refresh the page, or contact <a>Atlassian Support</a> if this keeps happening.',
116
- description: 'Describes possible actions when search throws an error'
117
67
  }
118
68
  });
@@ -1,15 +1,17 @@
1
1
  import { token } from '@atlaskit/tokens';
2
2
  import { css } from '@emotion/react';
3
- import { N500 } from '@atlaskit/theme/colors'; // AFP-2532 TODO: Fix automatic suppressions below
4
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
5
-
6
- import { typography } from '@atlaskit/theme';
7
- import { gridSize } from '@atlaskit/theme/constants';
3
+ import { N500 } from '@atlaskit/theme/colors';
4
+ import { gridSize as getGridSize } from '@atlaskit/theme/constants';
8
5
  const LINK_PICKER_WIDTH_IN_PX = 342;
9
- const LINK_PICKER_MIN_HEIGHT_IN_PX = 234;
6
+ const LINK_PICKER_MIN_HEIGHT_IN_PX = 220;
7
+ const gridSize = getGridSize();
8
+ /**
9
+ * Half padding on the top as the form field has a `gridSize()` margin top that cannot be overridden
10
+ */
11
+
10
12
  export const rootContainerStyles = css`
11
13
  width: ${LINK_PICKER_WIDTH_IN_PX}px;
12
- padding: ${gridSize() * 2}px;
14
+ padding: ${gridSize}px ${gridSize * 2}px ${gridSize * 2}px;
13
15
  box-sizing: border-box;
14
16
  line-height: initial;
15
17
  min-height: ${LINK_PICKER_MIN_HEIGHT_IN_PX}px;
@@ -21,16 +23,19 @@ export const rootContainerStylesForLoader = css`
21
23
  justify-content: center;
22
24
  `;
23
25
  export const searchIconStyles = css`
24
- margin-left: ${gridSize() / 2}px;
26
+ margin-left: ${gridSize / 2}px;
25
27
  color: ${token('color.icon', N500)};
26
28
  cursor: default;
27
29
  `;
28
- export const listTitleStyles = css`
29
- ${typography.h100()}
30
- text-transform: uppercase;
31
- margin-bottom: ${gridSize() / 2}px;
32
- `;
33
30
  export const tabsWrapperStyles = css`
34
- margin-left: -${gridSize()}px;
35
- margin-right: -${gridSize()}px;
31
+ margin-top: ${gridSize * 1.5}px;
32
+ margin-left: -${gridSize}px;
33
+ margin-right: -${gridSize}px;
34
+ `;
35
+ export const flexColumnStyles = css`
36
+ display: flex;
37
+ flex-direction: column;
38
+ `;
39
+ export const formFooterMargin = css`
40
+ margin-top: ${gridSize * 2}px;
36
41
  `;
@@ -11,5 +11,7 @@ export const clearTextButtonStyles = css`
11
11
  cursor: pointer;
12
12
  `;
13
13
  export const fieldStyles = css`
14
- margin-bottom: ${gridSize() * 2}px;
14
+ & + & {
15
+ margin-top: ${gridSize() * 2}px;
16
+ }
15
17
  `;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.8.3",
3
+ "version": "1.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,19 @@
1
+ import { useLayoutEffect, useRef } from 'react';
2
+
3
+ var useFixHeight = function useFixHeight(shouldFixHeight) {
4
+ var ref = useRef(null);
5
+ var currentHeight = useRef(null);
6
+ useLayoutEffect(function () {
7
+ if (ref.current) {
8
+ currentHeight.current = ref.current.getBoundingClientRect().height;
9
+ }
10
+ });
11
+ return {
12
+ ref: ref,
13
+ style: shouldFixHeight ? {
14
+ minHeight: currentHeight.current || 'auto'
15
+ } : undefined
16
+ };
17
+ };
18
+
19
+ export default useFixHeight;
@@ -1,38 +1,21 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
-
6
- 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; }
7
-
8
- 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; }
9
-
10
- import { useEffect, useReducer, useMemo, useRef, useState, useCallback } from 'react';
4
+ import { useEffect, useMemo, useState, useCallback } from 'react';
11
5
  import { RECENT_SEARCH_LIST_SIZE } from '../../ui/link-picker';
12
-
13
- function reducer(state, payload) {
14
- return _objectSpread(_objectSpread({}, state), payload);
15
- }
16
-
6
+ import { CancellationError, resolvePluginUpdates } from './utils';
7
+ import { usePluginReducer } from './reducer';
17
8
  export function usePlugins(state, activeTab, plugins) {
18
9
  var _useState = useState(0),
19
10
  _useState2 = _slicedToArray(_useState, 2),
20
11
  retries = _useState2[0],
21
12
  setRetries = _useState2[1];
22
13
 
23
- var _useReducer = useReducer(reducer, {
24
- items: null,
25
- error: null,
26
- isLoading: false
27
- }),
28
- _useReducer2 = _slicedToArray(_useReducer, 2),
29
- pluginState = _useReducer2[0],
30
- dispatch = _useReducer2[1];
14
+ var _usePluginReducer = usePluginReducer(),
15
+ _usePluginReducer2 = _slicedToArray(_usePluginReducer, 2),
16
+ pluginState = _usePluginReducer2[0],
17
+ dispatch = _usePluginReducer2[1];
31
18
 
32
- var items = pluginState.items,
33
- isLoading = pluginState.isLoading,
34
- error = pluginState.error;
35
- var queryVersion = useRef(0);
36
19
  var activePlugin = plugins === null || plugins === void 0 ? void 0 : plugins[activeTab];
37
20
  useEffect(function () {
38
21
  if (!activePlugin) {
@@ -41,107 +24,75 @@ export function usePlugins(state, activeTab, plugins) {
41
24
 
42
25
  if (!state) {
43
26
  dispatch({
44
- items: null,
45
- isLoading: false,
46
- error: null
27
+ type: 'CLEAR'
47
28
  });
48
29
  return;
49
30
  }
50
31
 
51
- var updates = activePlugin.resolve(state);
52
32
  dispatch({
53
- items: null,
54
- isLoading: true,
55
- error: null
33
+ type: 'LOADING'
56
34
  });
57
- var newQuery = ++queryVersion.current;
35
+
36
+ var _resolvePluginUpdates = resolvePluginUpdates(activePlugin, state),
37
+ next = _resolvePluginUpdates.next,
38
+ cancel = _resolvePluginUpdates.cancel;
58
39
 
59
40
  var updateResults = /*#__PURE__*/function () {
60
41
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
61
- var done, value, _result$done, result;
42
+ var _isLoading, _yield$next, value, done;
62
43
 
63
44
  return _regeneratorRuntime.wrap(function _callee$(_context) {
64
45
  while (1) {
65
46
  switch (_context.prev = _context.next) {
66
47
  case 0:
67
48
  _context.prev = 0;
49
+ _isLoading = true;
68
50
 
69
- case 1:
70
- if (!(newQuery === queryVersion.current)) {
71
- _context.next = 23;
72
- break;
73
- }
74
-
75
- done = false;
76
- value = void 0;
77
-
78
- if (!(updates instanceof Promise)) {
79
- _context.next = 11;
80
- break;
81
- }
82
-
83
- done = true;
84
- _context.next = 8;
85
- return updates;
86
-
87
- case 8:
88
- value = _context.sent;
89
- _context.next = 16;
90
- break;
91
-
92
- case 11:
93
- _context.next = 13;
94
- return updates.next();
95
-
96
- case 13:
97
- result = _context.sent;
98
- done = (_result$done = result.done) !== null && _result$done !== void 0 ? _result$done : false;
99
- value = result.value;
100
-
101
- case 16:
102
- if (!(newQuery !== queryVersion.current)) {
103
- _context.next = 18;
51
+ case 2:
52
+ if (!_isLoading) {
53
+ _context.next = 12;
104
54
  break;
105
55
  }
106
56
 
107
- return _context.abrupt("return");
57
+ _context.next = 5;
58
+ return next();
108
59
 
109
- case 18:
60
+ case 5:
61
+ _yield$next = _context.sent;
62
+ value = _yield$next.value;
63
+ done = _yield$next.done;
64
+ _isLoading = !done;
110
65
  dispatch({
111
- items: limit(value.data),
112
- isLoading: !done
66
+ type: 'SUCCESS',
67
+ payload: {
68
+ items: limit(value.data),
69
+ isLoading: !done
70
+ }
113
71
  });
114
-
115
- if (!done) {
116
- _context.next = 21;
117
- break;
118
- }
119
-
120
- return _context.abrupt("return");
121
-
122
- case 21:
123
- _context.next = 1;
72
+ _context.next = 2;
124
73
  break;
125
74
 
126
- case 23:
127
- _context.next = 28;
75
+ case 12:
76
+ _context.next = 17;
128
77
  break;
129
78
 
130
- case 25:
131
- _context.prev = 25;
79
+ case 14:
80
+ _context.prev = 14;
132
81
  _context.t0 = _context["catch"](0);
133
- dispatch({
134
- error: _context.t0,
135
- items: null,
136
- isLoading: false
137
- });
138
82
 
139
- case 28:
83
+ if (!(_context.t0 instanceof CancellationError)) {
84
+ dispatch({
85
+ type: 'ERROR',
86
+ payload: _context.t0
87
+ });
88
+ }
89
+
90
+ case 17:
140
91
  case "end":
141
92
  return _context.stop();
142
93
  }
143
94
  }
144
- }, _callee, null, [[0, 25]]);
95
+ }, _callee, null, [[0, 14]]);
145
96
  }));
146
97
 
147
98
  return function updateResults() {
@@ -150,7 +101,8 @@ export function usePlugins(state, activeTab, plugins) {
150
101
  }();
151
102
 
152
103
  updateResults();
153
- }, [activePlugin, queryVersion, state, retries]);
104
+ return cancel;
105
+ }, [activePlugin, state, retries, dispatch]);
154
106
  var tabs = useMemo(function () {
155
107
  if (!plugins || plugins.length <= 1) {
156
108
  return [];
@@ -169,6 +121,9 @@ export function usePlugins(state, activeTab, plugins) {
169
121
  return ++prev;
170
122
  });
171
123
  }, []);
124
+ var items = pluginState.items,
125
+ isLoading = pluginState.isLoading,
126
+ error = pluginState.error;
172
127
  return {
173
128
  tabs: tabs,
174
129
  items: items,
@@ -0,0 +1,43 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ 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; }
4
+
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; }
6
+
7
+ import { useReducer } from 'react';
8
+ export var ACTION_CLEAR = 'CLEAR';
9
+ export var ACTION_LOADING = 'LOADING';
10
+ export var ACTION_SUCCESS = 'SUCCESS';
11
+ export var ACTION_ERRORED = 'ERROR';
12
+ export var INITIAL_STATE = {
13
+ items: null,
14
+ error: null,
15
+ isLoading: false
16
+ };
17
+ export function reducer(state, action) {
18
+ switch (action.type) {
19
+ case ACTION_CLEAR:
20
+ return _objectSpread({}, INITIAL_STATE);
21
+
22
+ case ACTION_LOADING:
23
+ return _objectSpread(_objectSpread({}, INITIAL_STATE), {}, {
24
+ isLoading: true
25
+ });
26
+
27
+ case ACTION_SUCCESS:
28
+ return _objectSpread(_objectSpread(_objectSpread({}, state), action.payload), {}, {
29
+ error: null
30
+ });
31
+
32
+ case ACTION_ERRORED:
33
+ return _objectSpread(_objectSpread({}, INITIAL_STATE), {}, {
34
+ error: action.payload
35
+ });
36
+
37
+ default:
38
+ return state;
39
+ }
40
+ }
41
+ export var usePluginReducer = function usePluginReducer() {
42
+ return useReducer(reducer, INITIAL_STATE);
43
+ };
@@ -0,0 +1,111 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+
10
+ 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); }; }
11
+
12
+ 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; } }
13
+
14
+ export var CancellationError = /*#__PURE__*/function (_Error) {
15
+ _inherits(CancellationError, _Error);
16
+
17
+ var _super = _createSuper(CancellationError);
18
+
19
+ function CancellationError() {
20
+ _classCallCheck(this, CancellationError);
21
+
22
+ return _super.apply(this, arguments);
23
+ }
24
+
25
+ return _createClass(CancellationError);
26
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
27
+ export var cancellable = function cancellable(promise) {
28
+ var reject;
29
+ return {
30
+ promise: new Promise(function (resolve, _reject) {
31
+ reject = _reject;
32
+ promise.then(resolve, reject);
33
+ }),
34
+ cancel: function cancel() {
35
+ reject(new CancellationError('Promise cancelled'));
36
+ }
37
+ };
38
+ };
39
+ /**
40
+ * Wraps the resolve with a cancellation wrapper and makes promise + generator plugin resolves more compatible
41
+ * Calling cancel for generator plugin prevents it from yielding any further updates
42
+ */
43
+
44
+ export var resolvePluginUpdates = function resolvePluginUpdates(plugin, state) {
45
+ var updates = plugin.resolve(state); // Promise plugin
46
+
47
+ if (updates instanceof Promise) {
48
+ var _cancellable = cancellable(updates),
49
+ promise = _cancellable.promise,
50
+ cancel = _cancellable.cancel;
51
+
52
+ return {
53
+ cancel: cancel,
54
+ next: function () {
55
+ var _next = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
56
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
57
+ while (1) {
58
+ switch (_context.prev = _context.next) {
59
+ case 0:
60
+ _context.next = 2;
61
+ return promise;
62
+
63
+ case 2:
64
+ _context.t0 = _context.sent;
65
+ return _context.abrupt("return", {
66
+ value: _context.t0,
67
+ done: true
68
+ });
69
+
70
+ case 4:
71
+ case "end":
72
+ return _context.stop();
73
+ }
74
+ }
75
+ }, _callee);
76
+ }));
77
+
78
+ function next() {
79
+ return _next.apply(this, arguments);
80
+ }
81
+
82
+ return next;
83
+ }()
84
+ };
85
+ } // Generator plugin
86
+
87
+
88
+ var cancellationCallbacks = [];
89
+ var cancelled = false;
90
+ return {
91
+ cancel: function cancel() {
92
+ cancelled = true;
93
+ cancellationCallbacks.forEach(function (cb) {
94
+ return cb();
95
+ });
96
+ },
97
+ next: function next() {
98
+ var _cancellable2 = cancellable(updates.next()),
99
+ promise = _cancellable2.promise,
100
+ cancel = _cancellable2.cancel;
101
+
102
+ if (cancelled) {
103
+ cancel();
104
+ } else {
105
+ cancellationCallbacks.push(cancel);
106
+ }
107
+
108
+ return promise;
109
+ }
110
+ };
111
+ };
@@ -5,7 +5,7 @@ import { COMPONENT_NAME, ANALYTICS_CHANNEL } from '../common/constants';
5
5
  import { name as packageName, version as packageVersion } from '../version.json';
6
6
  import { ErrorBoundaryFallback } from './error-boundary-fallback';
7
7
  import { LoaderFallback } from './loader-fallback';
8
- var PACKAGE_DATA = {
8
+ export var PACKAGE_DATA = {
9
9
  packageName: packageName,
10
10
  packageVersion: packageVersion,
11
11
  componentName: COMPONENT_NAME
@@ -0,0 +1,53 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["isEditing", "onCancel"];
4
+
5
+ /** @jsx jsx */
6
+ import { jsx } from '@emotion/react';
7
+ import { useIntl, defineMessages } from 'react-intl-next';
8
+ import Button, { ButtonGroup } from '@atlaskit/button';
9
+ import { formFooterStyles } from './styled';
10
+ import { memo } from 'react';
11
+ var messages = defineMessages({
12
+ cancelButton: {
13
+ id: 'fabric.linkPicker.button.cancel',
14
+ defaultMessage: 'Cancel',
15
+ description: 'Button to cancel and dismiss the link picker'
16
+ },
17
+ saveButton: {
18
+ id: 'fabric.linkPicker.button.save',
19
+ defaultMessage: 'Save',
20
+ description: 'Button to save edited link'
21
+ },
22
+ insertButton: {
23
+ id: 'fabric.linkPicker.button.insert',
24
+ defaultMessage: 'Insert',
25
+ description: 'Button to insert searched or selected link'
26
+ }
27
+ });
28
+ export var testIds = {
29
+ insertButton: 'link-picker-insert-button',
30
+ cancelButton: 'link-picker-cancel-button'
31
+ };
32
+
33
+ var FormFooter = function FormFooter(_ref) {
34
+ var isEditing = _ref.isEditing,
35
+ onCancel = _ref.onCancel,
36
+ restProps = _objectWithoutProperties(_ref, _excluded);
37
+
38
+ var intl = useIntl();
39
+ var insertButtonMsg = isEditing ? messages.saveButton : messages.insertButton;
40
+ return jsx("footer", _extends({
41
+ css: formFooterStyles
42
+ }, restProps), jsx(ButtonGroup, null, jsx(Button, {
43
+ appearance: "default",
44
+ onClick: onCancel,
45
+ testId: testIds.cancelButton
46
+ }, intl.formatMessage(messages.cancelButton)), jsx(Button, {
47
+ type: "submit",
48
+ appearance: "primary",
49
+ testId: testIds.insertButton
50
+ }, intl.formatMessage(insertButtonMsg))));
51
+ };
52
+
53
+ export default /*#__PURE__*/memo(FormFooter);
@@ -0,0 +1,6 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject;
4
+
5
+ import { css } from '@emotion/react';
6
+ export var formFooterStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: flex-end;\n"])));