@atlaskit/share 3.7.1 → 3.7.2

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 (130) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/clients/AtlassianUrlShortenerClient.js +0 -22
  3. package/dist/cjs/clients/ShareServiceClient.js +1 -12
  4. package/dist/cjs/clients/index.js +0 -1
  5. package/dist/cjs/components/CommentField.js +0 -9
  6. package/dist/cjs/components/CopyLinkButton.js +8 -48
  7. package/dist/cjs/components/ErrorBoundary.js +0 -26
  8. package/dist/cjs/components/IntegrationButton.js +3 -15
  9. package/dist/cjs/components/IntegrationForm.js +8 -17
  10. package/dist/cjs/components/LazyShareForm/LazyShareForm.js +35 -51
  11. package/dist/cjs/components/LazyShareForm/index.js +0 -2
  12. package/dist/cjs/components/LazyShareForm/lazy.js +4 -18
  13. package/dist/cjs/components/MessagesIntlProvider.js +1 -14
  14. package/dist/cjs/components/ShareButton.js +1 -9
  15. package/dist/cjs/components/ShareDialogContainer.js +55 -124
  16. package/dist/cjs/components/ShareDialogWithTrigger.js +85 -159
  17. package/dist/cjs/components/ShareForm.js +41 -100
  18. package/dist/cjs/components/ShareFormWrapper/ShareFormWrapper.js +5 -11
  19. package/dist/cjs/components/ShareFormWrapper/index.js +0 -2
  20. package/dist/cjs/components/ShareFormWrapper/styled.js +2 -9
  21. package/dist/cjs/components/ShareHeader.js +0 -14
  22. package/dist/cjs/components/SlackIcon.js +0 -4
  23. package/dist/cjs/components/SplitButton.js +18 -43
  24. package/dist/cjs/components/UserPickerField.js +20 -70
  25. package/dist/cjs/components/analytics/analytics.js +6 -39
  26. package/dist/cjs/components/analytics/ufoExperienceHelper.js +0 -4
  27. package/dist/cjs/components/analytics/ufoExperiences.js +0 -2
  28. package/dist/cjs/components/colorSlackIcon.js +0 -4
  29. package/dist/cjs/components/localStorageUtils.js +0 -11
  30. package/dist/cjs/components/monochromeSlackIcon.js +2 -4
  31. package/dist/cjs/components/styles.js +2 -16
  32. package/dist/cjs/components/utils.js +4 -19
  33. package/dist/cjs/i18n/cs.js +0 -1
  34. package/dist/cjs/i18n/da.js +0 -1
  35. package/dist/cjs/i18n/de.js +0 -1
  36. package/dist/cjs/i18n/en.js +0 -1
  37. package/dist/cjs/i18n/en_GB.js +0 -1
  38. package/dist/cjs/i18n/en_ZZ.js +0 -1
  39. package/dist/cjs/i18n/es.js +0 -1
  40. package/dist/cjs/i18n/et.js +0 -1
  41. package/dist/cjs/i18n/fi.js +0 -1
  42. package/dist/cjs/i18n/fr.js +0 -1
  43. package/dist/cjs/i18n/hu.js +0 -1
  44. package/dist/cjs/i18n/index.js +0 -31
  45. package/dist/cjs/i18n/is.js +0 -1
  46. package/dist/cjs/i18n/it.js +0 -1
  47. package/dist/cjs/i18n/ja.js +0 -1
  48. package/dist/cjs/i18n/ko.js +0 -1
  49. package/dist/cjs/i18n/languages.js +0 -1
  50. package/dist/cjs/i18n/nb.js +0 -1
  51. package/dist/cjs/i18n/nl.js +0 -1
  52. package/dist/cjs/i18n/pl.js +0 -1
  53. package/dist/cjs/i18n/pt_BR.js +0 -1
  54. package/dist/cjs/i18n/pt_PT.js +0 -1
  55. package/dist/cjs/i18n/ro.js +0 -1
  56. package/dist/cjs/i18n/ru.js +0 -1
  57. package/dist/cjs/i18n/sk.js +0 -1
  58. package/dist/cjs/i18n/sv.js +0 -1
  59. package/dist/cjs/i18n/th.js +0 -1
  60. package/dist/cjs/i18n/tr.js +0 -1
  61. package/dist/cjs/i18n/uk.js +0 -1
  62. package/dist/cjs/i18n/vi.js +0 -1
  63. package/dist/cjs/i18n/zh.js +0 -1
  64. package/dist/cjs/i18n/zh_TW.js +0 -1
  65. package/dist/cjs/i18n.js +2 -3
  66. package/dist/cjs/index.js +0 -3
  67. package/dist/cjs/types/ShareEntities.js +0 -1
  68. package/dist/cjs/types/index.js +0 -2
  69. package/dist/cjs/util/i18n-util.js +2 -8
  70. package/dist/cjs/version.json +1 -1
  71. package/dist/es2019/clients/AtlassianUrlShortenerClient.js +0 -6
  72. package/dist/es2019/clients/ShareServiceClient.js +1 -4
  73. package/dist/es2019/components/CopyLinkButton.js +2 -13
  74. package/dist/es2019/components/ErrorBoundary.js +0 -10
  75. package/dist/es2019/components/IntegrationButton.js +0 -2
  76. package/dist/es2019/components/LazyShareForm/LazyShareForm.js +2 -4
  77. package/dist/es2019/components/LazyShareForm/lazy.js +3 -5
  78. package/dist/es2019/components/MessagesIntlProvider.js +2 -3
  79. package/dist/es2019/components/ShareDialogContainer.js +19 -59
  80. package/dist/es2019/components/ShareDialogWithTrigger.js +28 -65
  81. package/dist/es2019/components/ShareForm.js +4 -24
  82. package/dist/es2019/components/ShareFormWrapper/ShareFormWrapper.js +0 -2
  83. package/dist/es2019/components/ShareFormWrapper/styled.js +2 -1
  84. package/dist/es2019/components/SlackIcon.js +0 -2
  85. package/dist/es2019/components/SplitButton.js +2 -5
  86. package/dist/es2019/components/UserPickerField.js +2 -23
  87. package/dist/es2019/components/analytics/analytics.js +9 -13
  88. package/dist/es2019/components/analytics/ufoExperienceHelper.js +0 -2
  89. package/dist/es2019/components/colorSlackIcon.js +0 -2
  90. package/dist/es2019/components/localStorageUtils.js +0 -3
  91. package/dist/es2019/components/monochromeSlackIcon.js +2 -2
  92. package/dist/es2019/components/styles.js +3 -2
  93. package/dist/es2019/components/utils.js +7 -8
  94. package/dist/es2019/i18n.js +2 -1
  95. package/dist/es2019/index.js +2 -1
  96. package/dist/es2019/types/ShareEntities.js +1 -1
  97. package/dist/es2019/util/i18n-util.js +1 -5
  98. package/dist/es2019/version.json +1 -1
  99. package/dist/esm/clients/AtlassianUrlShortenerClient.js +0 -16
  100. package/dist/esm/clients/ShareServiceClient.js +1 -7
  101. package/dist/esm/components/CopyLinkButton.js +8 -31
  102. package/dist/esm/components/ErrorBoundary.js +0 -18
  103. package/dist/esm/components/IntegrationButton.js +3 -8
  104. package/dist/esm/components/IntegrationForm.js +8 -10
  105. package/dist/esm/components/LazyShareForm/LazyShareForm.js +35 -37
  106. package/dist/esm/components/LazyShareForm/lazy.js +5 -7
  107. package/dist/esm/components/MessagesIntlProvider.js +1 -6
  108. package/dist/esm/components/ShareButton.js +1 -2
  109. package/dist/esm/components/ShareDialogContainer.js +55 -109
  110. package/dist/esm/components/ShareDialogWithTrigger.js +89 -155
  111. package/dist/esm/components/ShareForm.js +41 -74
  112. package/dist/esm/components/ShareFormWrapper/ShareFormWrapper.js +5 -7
  113. package/dist/esm/components/ShareFormWrapper/styled.js +2 -1
  114. package/dist/esm/components/ShareHeader.js +0 -2
  115. package/dist/esm/components/SlackIcon.js +0 -2
  116. package/dist/esm/components/SplitButton.js +18 -24
  117. package/dist/esm/components/UserPickerField.js +20 -54
  118. package/dist/esm/components/analytics/analytics.js +6 -15
  119. package/dist/esm/components/analytics/ufoExperienceHelper.js +0 -2
  120. package/dist/esm/components/colorSlackIcon.js +0 -2
  121. package/dist/esm/components/localStorageUtils.js +0 -3
  122. package/dist/esm/components/monochromeSlackIcon.js +2 -2
  123. package/dist/esm/components/styles.js +2 -7
  124. package/dist/esm/components/utils.js +7 -8
  125. package/dist/esm/i18n.js +2 -1
  126. package/dist/esm/index.js +2 -1
  127. package/dist/esm/types/ShareEntities.js +1 -1
  128. package/dist/esm/util/i18n-util.js +1 -5
  129. package/dist/esm/version.json +1 -1
  130. package/package.json +2 -2
@@ -1,5 +1,4 @@
1
1
  /** @jsx jsx */
2
-
3
2
  /** @jsxFrag */
4
3
  import React from 'react';
5
4
  import { jsx } from '@emotion/react';
@@ -12,7 +11,6 @@ import { IntegrationForm } from '../IntegrationForm';
12
11
  import { ShareForm } from '../ShareForm';
13
12
  import { ShareFormWrapper } from '../ShareFormWrapper';
14
13
  import { allowEmails } from '../utils';
15
-
16
14
  /**
17
15
  * A Share form content which is lazy-loaded.
18
16
  * Make sure this component is not exported inside main entry points `src/index.ts`
@@ -71,7 +69,8 @@ function LazyShareForm(props) {
71
69
  });
72
70
  const allowEmail = allowEmails(config);
73
71
  return jsx(ShareFormWrapper, {
74
- footer: footer // form title will be determined by `title` and `showTitle` prop passed to `ShareForm`,
72
+ footer: footer
73
+ // form title will be determined by `title` and `showTitle` prop passed to `ShareForm`,
75
74
  // so we don't need to show title via ShareFormWrapper
76
75
  ,
77
76
  shouldShowTitle: false
@@ -114,5 +113,4 @@ function LazyShareForm(props) {
114
113
  isBrowseUsersDisabled: isBrowseUsersDisabled
115
114
  }) : jsx("p", null, jsx(FormattedMessage, messages.formNoPermissions))));
116
115
  }
117
-
118
116
  export default LazyShareForm;
@@ -4,12 +4,10 @@ import { jsx } from '@emotion/react';
4
4
  import { lazyForPaint, LazySuspense } from 'react-loosely-lazy';
5
5
  import Spinner from '@atlaskit/spinner';
6
6
  import { ShareFormWrapper } from '../ShareFormWrapper';
7
- const LazyShareFormLazy = lazyForPaint(() => import(
8
- /* webpackChunkName: "@atlaskit-internal_share-form" */
7
+ const LazyShareFormLazy = lazyForPaint(() => import( /* webpackChunkName: "@atlaskit-internal_share-form" */
9
8
  './LazyShareForm'), {
10
9
  ssr: false
11
10
  });
12
-
13
11
  const LoadingDialog = ({
14
12
  shareFormTitle,
15
13
  showTitle,
@@ -19,7 +17,8 @@ const LoadingDialog = ({
19
17
  setIsLoading(true);
20
18
  });
21
19
  return jsx(ShareFormWrapper, {
22
- shareFormTitle: shareFormTitle // if `showTitle` is passed, we use it. Otherwise, we will show title for loading dialog.
20
+ shareFormTitle: shareFormTitle
21
+ // if `showTitle` is passed, we use it. Otherwise, we will show title for loading dialog.
23
22
  ,
24
23
  shouldShowTitle: typeof showTitle === 'boolean' ? showTitle : true
25
24
  }, jsx("div", {
@@ -32,7 +31,6 @@ const LoadingDialog = ({
32
31
  }
33
32
  }, jsx(Spinner, null)));
34
33
  };
35
-
36
34
  export default (props => jsx(LazySuspense, {
37
35
  fallback: jsx(LoadingDialog, {
38
36
  shareFormTitle: props.shareFormTitle,
@@ -1,13 +1,13 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { injectIntl, IntlProvider } from 'react-intl-next';
3
3
  import { getMessagesForLocale } from '../util/i18n-util';
4
-
5
4
  const MessagesIntlProvider = ({
6
5
  intl,
7
6
  children
8
7
  }) => {
9
8
  const mergedMessages = useMemo(() => {
10
- return { ...intl.messages,
9
+ return {
10
+ ...intl.messages,
11
11
  ...getMessagesForLocale(intl.locale)
12
12
  };
13
13
  }, [intl.messages, intl.locale]);
@@ -16,5 +16,4 @@ const MessagesIntlProvider = ({
16
16
  messages: mergedMessages
17
17
  }, children);
18
18
  };
19
-
20
19
  export default injectIntl(MessagesIntlProvider);
@@ -20,37 +20,31 @@ export const defaultConfig = {
20
20
  disableSharingToEmails: false
21
21
  };
22
22
  const memoizedFormatCopyLink = memoizeOne((origin, link) => origin.addToUrl(link));
23
-
24
23
  function getCurrentPageUrl() {
25
24
  return window.location.href;
26
25
  }
26
+
27
27
  /**
28
28
  * This component serves as a Provider to provide customizable implementations
29
29
  * to ShareDialogTrigger component
30
30
  */
31
31
  // eslint-disable-next-line @repo/internal/react/no-class-components
32
-
33
-
34
32
  export class ShareDialogContainerInternal extends React.Component {
35
33
  constructor(props) {
36
- super(props); // v0.4 -> v0.5 .client -> .shareClient
34
+ super(props);
37
35
 
36
+ // v0.4 -> v0.5 .client -> .shareClient
38
37
  _defineProperty(this, "_isMounted", false);
39
-
40
38
  _defineProperty(this, "_urlShorteningRequestCounter", 0);
41
-
42
39
  _defineProperty(this, "_lastUrlShorteningWasTooSlow", false);
43
-
44
40
  _defineProperty(this, "createAndFireEvent", payload => {
45
41
  const {
46
42
  createAnalyticsEvent
47
43
  } = this.props;
48
-
49
44
  if (createAnalyticsEvent) {
50
45
  createAnalyticsEvent(payload).fire(CHANNEL_ID);
51
46
  }
52
47
  });
53
-
54
48
  _defineProperty(this, "fetchConfig", () => {
55
49
  this.setState({
56
50
  isFetchingConfig: true
@@ -58,14 +52,12 @@ export class ShareDialogContainerInternal extends React.Component {
58
52
  try {
59
53
  renderShareDialogExp.start();
60
54
  const config = await this.shareClient.getConfig(this.props.cloudId);
61
-
62
55
  if (this._isMounted) {
63
56
  this.setState({
64
57
  config,
65
58
  isFetchingConfig: false
66
59
  });
67
60
  }
68
-
69
61
  renderShareDialogExp.success();
70
62
  } catch (error) {
71
63
  if (this._isMounted) {
@@ -74,21 +66,19 @@ export class ShareDialogContainerInternal extends React.Component {
74
66
  isFetchingConfig: false
75
67
  });
76
68
  }
77
-
78
- let { ...errObj
69
+ let {
70
+ ...errObj
79
71
  } = error;
80
-
81
72
  if (error instanceof Error) {
82
- errObj = { ...errObj,
73
+ errObj = {
74
+ ...errObj,
83
75
  className: error.constructor.name
84
76
  };
85
77
  }
86
-
87
78
  isValidFailedExperience(renderShareDialogExp, errObj);
88
79
  }
89
80
  });
90
81
  });
91
-
92
82
  _defineProperty(this, "handleSubmitShare", ({
93
83
  users,
94
84
  comment
@@ -115,54 +105,49 @@ export class ShareDialogContainerInternal extends React.Component {
115
105
  return this.shareClient.share(content, optionDataToUsers(users), metaData, comment).then(() => {
116
106
  if (!this._isMounted) {
117
107
  return;
118
- } // renew Origin Tracing Id per share action succeeded
119
-
108
+ }
120
109
 
110
+ // renew Origin Tracing Id per share action succeeded
121
111
  this.setState(state => ({
122
112
  shareActionCount: state.shareActionCount + 1
123
113
  }));
124
114
  });
125
115
  });
126
-
127
116
  _defineProperty(this, "handleDialogOpen", async () => {
128
117
  if (this.props.onDialogOpen) {
129
118
  this.props.onDialogOpen();
130
119
  }
131
-
132
120
  this.setState({
133
121
  currentPageUrl: getCurrentPageUrl()
134
122
  }, () => {
135
123
  this.updateShortCopyLink();
136
- }); // always refetch the config when modal is re-opened
124
+ });
137
125
 
126
+ // always refetch the config when modal is re-opened
138
127
  this.fetchConfig();
139
128
  });
140
-
141
129
  _defineProperty(this, "decorateAnalytics", payload => {
142
130
  if (payload.type === COPY_LINK_EVENT.type && payload.action === COPY_LINK_EVENT.action && payload.actionSubjectId === COPY_LINK_EVENT.actionSubjectId) {
143
131
  const isCopyLinkShortened = !!this.getShortenedCopyLink();
144
- payload = { ...payload,
145
- attributes: { ...payload.attributes,
132
+ payload = {
133
+ ...payload,
134
+ attributes: {
135
+ ...payload.attributes,
146
136
  shortUrl: isCopyLinkShortened
147
137
  }
148
138
  };
149
-
150
139
  if (this.shouldShortenCopyLink() && !isCopyLinkShortened) {
151
140
  this._lastUrlShorteningWasTooSlow = true;
152
141
  }
153
142
  }
154
-
155
143
  return payload;
156
144
  });
157
-
158
145
  _defineProperty(this, "getUniqueCopyLinkOriginTracing", memoizeOne((link, originTracingFactory) => {
159
146
  return originTracingFactory();
160
147
  }));
161
-
162
148
  _defineProperty(this, "getUniqueFormShareOriginTracing", memoizeOne((link, originTracingFactory, shareCount) => {
163
149
  return originTracingFactory();
164
150
  }));
165
-
166
151
  _defineProperty(this, "getUpToDateShortenedCopyLink", memoizeOne(data => {
167
152
  this._lastUrlShorteningWasTooSlow = false;
168
153
  this._urlShorteningRequestCounter++;
@@ -176,12 +161,10 @@ export class ShareDialogContainerInternal extends React.Component {
176
161
  return null;
177
162
  });
178
163
  }, deepEqual));
179
-
180
164
  _defineProperty(this, "getFormShareLink", () => {
181
165
  // original share link is used here
182
166
  return this.getRawLink();
183
167
  });
184
-
185
168
  assert(!props.client, 'elements/share: Breaking change, please update your props!');
186
169
  this.shareClient = props.shareClient || new ShareServiceClient();
187
170
  this.urlShortenerClient = props.urlShortenerClient || new AtlassianUrlShortenerClient();
@@ -193,21 +176,17 @@ export class ShareDialogContainerInternal extends React.Component {
193
176
  shortenedCopyLink: null
194
177
  };
195
178
  }
196
-
197
179
  componentDidMount() {
198
180
  this._isMounted = true;
199
181
  }
200
-
201
182
  componentWillUnmount() {
202
183
  this._isMounted = false;
203
184
  }
204
-
205
185
  componentDidUpdate(prevProps) {
206
186
  if (!deepEqual(this.getShortLinkData(prevProps), this.getShortLinkData(this.props))) {
207
187
  this.updateShortCopyLink();
208
188
  }
209
189
  }
210
-
211
190
  getRawLink() {
212
191
  const {
213
192
  shareLink
@@ -217,7 +196,6 @@ export class ShareDialogContainerInternal extends React.Component {
217
196
  } = this.state;
218
197
  return shareLink || currentPageUrl;
219
198
  }
220
-
221
199
  getCopyLinkOriginTracing() {
222
200
  const {
223
201
  originTracingFactory
@@ -225,7 +203,6 @@ export class ShareDialogContainerInternal extends React.Component {
225
203
  const shareLink = this.getRawLink();
226
204
  return this.getUniqueCopyLinkOriginTracing(shareLink, originTracingFactory);
227
205
  }
228
-
229
206
  getFormShareOriginTracing() {
230
207
  const {
231
208
  originTracingFactory
@@ -236,7 +213,6 @@ export class ShareDialogContainerInternal extends React.Component {
236
213
  const shareLink = this.getRawLink();
237
214
  return this.getUniqueFormShareOriginTracing(shareLink, originTracingFactory, shareActionCount);
238
215
  }
239
-
240
216
  getFullCopyLink() {
241
217
  const {
242
218
  formatCopyLink
@@ -245,24 +221,19 @@ export class ShareDialogContainerInternal extends React.Component {
245
221
  const copyLinkOrigin = this.getCopyLinkOriginTracing();
246
222
  return (formatCopyLink || memoizedFormatCopyLink)(copyLinkOrigin, shareLink);
247
223
  }
248
-
249
224
  shouldShortenCopyLink() {
250
225
  return !!this.props.shortLinkData || !!this.props.useUrlShortener;
251
226
  }
252
-
253
227
  getShortenedCopyLink() {
254
228
  return this.shouldShortenCopyLink() && this.state.shortenedCopyLink || undefined;
255
229
  }
256
-
257
230
  getCopyLink() {
258
231
  return this.getShortenedCopyLink() || this.getFullCopyLink();
259
232
  }
260
-
261
233
  addOriginToShortQuery(query = '') {
262
234
  const copyLinkOrigin = this.getCopyLinkOriginTracing();
263
235
  return copyLinkOrigin.addToUrl(query);
264
236
  }
265
-
266
237
  getShortLinkData(props) {
267
238
  let {
268
239
  shortLinkData,
@@ -270,14 +241,14 @@ export class ShareDialogContainerInternal extends React.Component {
270
241
  cloudId,
271
242
  product
272
243
  } = props;
273
-
274
244
  if (shortLinkData) {
275
- return { ...shortLinkData,
245
+ return {
246
+ ...shortLinkData,
276
247
  query: this.addOriginToShortQuery(shortLinkData.query)
277
248
  };
278
- } // Use the legacy link type if old API is being used
279
-
249
+ }
280
250
 
251
+ // Use the legacy link type if old API is being used
281
252
  if (useUrlShortener && product === 'confluence') {
282
253
  return {
283
254
  cloudId,
@@ -288,39 +259,31 @@ export class ShareDialogContainerInternal extends React.Component {
288
259
  }
289
260
  };
290
261
  }
291
-
292
262
  return undefined;
293
263
  }
294
-
295
264
  updateShortCopyLink() {
296
265
  this.setState({
297
266
  shortenedCopyLink: null
298
267
  });
299
268
  const shortLinkData = this.getShortLinkData(this.props);
300
-
301
269
  if (!shortLinkData) {
302
270
  return;
303
271
  }
304
-
305
272
  const shortLink = this.getUpToDateShortenedCopyLink(shortLinkData);
306
273
  const requestCounter = this._urlShorteningRequestCounter;
307
274
  shortLink.then(shortenedCopyLink => {
308
275
  if (!this._isMounted) {
309
276
  return;
310
277
  }
311
-
312
278
  const isRequestOutdated = requestCounter !== this._urlShorteningRequestCounter;
313
-
314
279
  if (isRequestOutdated) {
315
280
  return;
316
281
  }
317
-
318
282
  this.setState({
319
283
  shortenedCopyLink
320
284
  });
321
285
  });
322
286
  }
323
-
324
287
  render() {
325
288
  const {
326
289
  cloudId,
@@ -409,13 +372,10 @@ export class ShareDialogContainerInternal extends React.Component {
409
372
  isBrowseUsersDisabled: isBrowseUsersDisabled
410
373
  })));
411
374
  }
412
-
413
375
  }
414
-
415
376
  _defineProperty(ShareDialogContainerInternal, "defaultProps", {
416
377
  enableSmartUserPicker: false,
417
378
  shareeAction: 'view',
418
379
  product: 'confluence'
419
380
  });
420
-
421
381
  export const ShareDialogContainer = withAnalyticsEvents()(ShareDialogContainerInternal);