@atlaskit/share 5.0.0 → 5.0.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-jira/tsconfig.json +3 -0
  4. package/dist/cjs/components/CopyLinkButton.js +11 -7
  5. package/dist/cjs/components/CopyLinkButtonNext.compiled.css +8 -0
  6. package/dist/cjs/components/CopyLinkButtonNext.js +180 -0
  7. package/dist/cjs/components/IntegrationButton.js +10 -1
  8. package/dist/cjs/components/IntegrationButtonNext.compiled.css +7 -0
  9. package/dist/cjs/components/IntegrationButtonNext.js +38 -0
  10. package/dist/cjs/components/LazyShareForm/LazyShareFormNext.compiled.css +5 -0
  11. package/dist/cjs/components/LazyShareForm/LazyShareFormNext.js +138 -0
  12. package/dist/cjs/components/LazyShareForm/lazy.js +3 -1
  13. package/dist/cjs/components/LazyShareForm/lazyNext.compiled.css +5 -0
  14. package/dist/cjs/components/LazyShareForm/lazyNext.js +58 -0
  15. package/dist/cjs/components/ShareDialogWithTrigger.js +12 -8
  16. package/dist/cjs/components/ShareDialogWithTriggerNext.compiled.css +4 -0
  17. package/dist/cjs/components/ShareDialogWithTriggerNext.js +653 -0
  18. package/dist/cjs/components/ShareFormNext.compiled.css +21 -0
  19. package/dist/cjs/components/ShareFormNext.js +473 -0
  20. package/dist/cjs/components/ShareFormWrapper/ShareFormWrapper.js +6 -2
  21. package/dist/cjs/components/ShareFormWrapper/compiled.compiled.css +7 -0
  22. package/dist/cjs/components/ShareFormWrapper/compiled.js +48 -0
  23. package/dist/cjs/components/SplitButton.js +25 -17
  24. package/dist/cjs/components/UserPickerField.js +3 -1
  25. package/dist/cjs/components/analytics/analytics.js +1 -1
  26. package/dist/es2019/components/CopyLinkButton.js +3 -1
  27. package/dist/es2019/components/CopyLinkButtonNext.compiled.css +8 -0
  28. package/dist/es2019/components/CopyLinkButtonNext.js +151 -0
  29. package/dist/es2019/components/IntegrationButton.js +9 -1
  30. package/dist/es2019/components/IntegrationButtonNext.compiled.css +7 -0
  31. package/dist/es2019/components/IntegrationButtonNext.js +33 -0
  32. package/dist/es2019/components/LazyShareForm/LazyShareFormNext.compiled.css +5 -0
  33. package/dist/es2019/components/LazyShareForm/LazyShareFormNext.js +136 -0
  34. package/dist/es2019/components/LazyShareForm/lazy.js +3 -1
  35. package/dist/es2019/components/LazyShareForm/lazyNext.compiled.css +5 -0
  36. package/dist/es2019/components/LazyShareForm/lazyNext.js +43 -0
  37. package/dist/es2019/components/ShareDialogWithTrigger.js +4 -2
  38. package/dist/es2019/components/ShareDialogWithTriggerNext.compiled.css +4 -0
  39. package/dist/es2019/components/ShareDialogWithTriggerNext.js +593 -0
  40. package/dist/es2019/components/ShareFormNext.compiled.css +21 -0
  41. package/dist/es2019/components/ShareFormNext.js +417 -0
  42. package/dist/es2019/components/ShareFormWrapper/ShareFormWrapper.js +6 -2
  43. package/dist/es2019/components/ShareFormWrapper/compiled.compiled.css +7 -0
  44. package/dist/es2019/components/ShareFormWrapper/compiled.js +41 -0
  45. package/dist/es2019/components/SplitButton.js +9 -3
  46. package/dist/es2019/components/UserPickerField.js +3 -1
  47. package/dist/es2019/components/analytics/analytics.js +1 -1
  48. package/dist/esm/components/CopyLinkButton.js +10 -6
  49. package/dist/esm/components/CopyLinkButtonNext.compiled.css +8 -0
  50. package/dist/esm/components/CopyLinkButtonNext.js +173 -0
  51. package/dist/esm/components/IntegrationButton.js +11 -1
  52. package/dist/esm/components/IntegrationButtonNext.compiled.css +7 -0
  53. package/dist/esm/components/IntegrationButtonNext.js +31 -0
  54. package/dist/esm/components/LazyShareForm/LazyShareFormNext.compiled.css +5 -0
  55. package/dist/esm/components/LazyShareForm/LazyShareFormNext.js +131 -0
  56. package/dist/esm/components/LazyShareForm/lazy.js +3 -1
  57. package/dist/esm/components/LazyShareForm/lazyNext.compiled.css +5 -0
  58. package/dist/esm/components/LazyShareForm/lazyNext.js +46 -0
  59. package/dist/esm/components/ShareDialogWithTrigger.js +11 -7
  60. package/dist/esm/components/ShareDialogWithTriggerNext.compiled.css +4 -0
  61. package/dist/esm/components/ShareDialogWithTriggerNext.js +646 -0
  62. package/dist/esm/components/ShareFormNext.compiled.css +21 -0
  63. package/dist/esm/components/ShareFormNext.js +463 -0
  64. package/dist/esm/components/ShareFormWrapper/ShareFormWrapper.js +6 -2
  65. package/dist/esm/components/ShareFormWrapper/compiled.compiled.css +7 -0
  66. package/dist/esm/components/ShareFormWrapper/compiled.js +41 -0
  67. package/dist/esm/components/SplitButton.js +25 -17
  68. package/dist/esm/components/UserPickerField.js +3 -1
  69. package/dist/esm/components/analytics/analytics.js +1 -1
  70. package/dist/types/components/CopyLinkButton.d.ts +2 -1
  71. package/dist/types/components/CopyLinkButtonNext.d.ts +35 -0
  72. package/dist/types/components/IntegrationButtonNext.d.ts +11 -0
  73. package/dist/types/components/LazyShareForm/LazyShareFormNext.d.ts +21 -0
  74. package/dist/types/components/LazyShareForm/lazyNext.d.ts +4 -0
  75. package/dist/types/components/ShareDialogWithTrigger.d.ts +3 -3
  76. package/dist/types/components/ShareDialogWithTriggerNext.d.ts +47 -0
  77. package/dist/types/components/ShareFormNext.d.ts +9 -0
  78. package/dist/types/components/ShareFormWrapper/compiled.d.ts +10 -0
  79. package/dist/types-ts4.5/components/CopyLinkButton.d.ts +2 -1
  80. package/dist/types-ts4.5/components/CopyLinkButtonNext.d.ts +35 -0
  81. package/dist/types-ts4.5/components/IntegrationButtonNext.d.ts +11 -0
  82. package/dist/types-ts4.5/components/LazyShareForm/LazyShareFormNext.d.ts +21 -0
  83. package/dist/types-ts4.5/components/LazyShareForm/lazyNext.d.ts +4 -0
  84. package/dist/types-ts4.5/components/ShareDialogWithTrigger.d.ts +3 -3
  85. package/dist/types-ts4.5/components/ShareDialogWithTriggerNext.d.ts +47 -0
  86. package/dist/types-ts4.5/components/ShareFormNext.d.ts +9 -0
  87. package/dist/types-ts4.5/components/ShareFormWrapper/compiled.d.ts +10 -0
  88. package/package.json +15 -11
@@ -0,0 +1,646 @@
1
+ /* ShareDialogWithTriggerNext.tsx generated by @compiled/babel-plugin v0.36.1 */
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _inherits from "@babel/runtime/helpers/inherits";
8
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
+ import "./ShareDialogWithTriggerNext.compiled.css";
10
+ import { ax, ix } from "@compiled/react/runtime";
11
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
15
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
16
+ import React from 'react';
17
+ import { FormattedMessage, injectIntl } from 'react-intl-next';
18
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
19
+ import { cx } from '@atlaskit/css';
20
+ import ShareIcon from '@atlaskit/icon/core/migration/share';
21
+ import { fg } from '@atlaskit/platform-feature-flags';
22
+ import Popup from '@atlaskit/popup';
23
+ import Portal from '@atlaskit/portal';
24
+ import { Box } from '@atlaskit/primitives/compiled';
25
+ import { layers } from '@atlaskit/theme/constants';
26
+ import Aktooltip from '@atlaskit/tooltip';
27
+ import { messages } from '../i18n';
28
+ import { OBJECT_SHARED } from '../types';
29
+ import { cancelShare, CHANNEL_ID, copyLinkButtonClicked, formShareSubmitted, screenEvent, shareMenuItemClicked, shareSplitButtonEvent, shareTabClicked, shareTriggerButtonClicked } from './analytics/analytics';
30
+ import { isValidFailedExperience } from './analytics/ufoExperienceHelper';
31
+ import { renderShareDialogExp, shareSubmitExp } from './analytics/ufoExperiences';
32
+ import LazyShareFormLazy from './LazyShareForm/lazy';
33
+ import ShareButton from './ShareButton';
34
+ import SplitButton from './SplitButton';
35
+ import { generateSelectZIndex, resolveShareFooter } from './utils';
36
+ var styles = {
37
+ shareButtonWrapperStyles: "_12ji1r31 _1qu2glyw _12y31o36 _1e0c116y",
38
+ outlineNone: "_12ji1r31 _1qu2glyw _12y31o36"
39
+ };
40
+ export var defaultShareContentState = {
41
+ users: [],
42
+ comment: {
43
+ format: 'plain_text',
44
+ value: ''
45
+ }
46
+ };
47
+ export var IconShare = function IconShare() {
48
+ return /*#__PURE__*/React.createElement(ShareIcon, {
49
+ spacing: "spacious",
50
+ label: "",
51
+ color: "currentColor"
52
+ });
53
+ };
54
+
55
+ // eslint-disable-next-line @repo/internal/react/no-class-components
56
+ export var ShareDialogWithTriggerInternal = /*#__PURE__*/function (_React$PureComponent) {
57
+ function ShareDialogWithTriggerInternal() {
58
+ var _this;
59
+ _classCallCheck(this, ShareDialogWithTriggerInternal);
60
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
61
+ args[_key] = arguments[_key];
62
+ }
63
+ _this = _callSuper(this, ShareDialogWithTriggerInternal, [].concat(args));
64
+ _defineProperty(_this, "containerRef", /*#__PURE__*/React.createRef());
65
+ /**
66
+ * Because the PopUp component has a higher zIndex it causes
67
+ * the select to be rendered within it, and add scrollbars.
68
+ * We will render the select options the PopUp outside,
69
+ */
70
+ _defineProperty(_this, "selectPortalRef", /*#__PURE__*/React.createRef());
71
+ _defineProperty(_this, "start", 0);
72
+ _defineProperty(_this, "state", {
73
+ isDialogOpen: false,
74
+ isSharing: false,
75
+ ignoreIntermediateState: false,
76
+ defaultValue: defaultShareContentState,
77
+ isUsingSplitButton: false,
78
+ showIntegrationForm: false,
79
+ selectedIntegration: null,
80
+ tabIndex: 0,
81
+ isMenuItemSelected: false,
82
+ isLoading: false
83
+ });
84
+ _defineProperty(_this, "closeAndResetDialog", function () {
85
+ _this.setState({
86
+ defaultValue: defaultShareContentState,
87
+ ignoreIntermediateState: true,
88
+ shareError: undefined,
89
+ isDialogOpen: false,
90
+ showIntegrationForm: false,
91
+ selectedIntegration: null,
92
+ isMenuItemSelected: false
93
+ });
94
+ var _this$props = _this.props,
95
+ onUserSelectionChange = _this$props.onUserSelectionChange,
96
+ onDialogClose = _this$props.onDialogClose;
97
+ if (onUserSelectionChange) {
98
+ onUserSelectionChange(defaultShareContentState.users);
99
+ }
100
+ if (onDialogClose) {
101
+ onDialogClose();
102
+ }
103
+ });
104
+ _defineProperty(_this, "createAndFireEvent", function (payload) {
105
+ var _this$props2 = _this.props,
106
+ createAnalyticsEvent = _this$props2.createAnalyticsEvent,
107
+ analyticsDecorator = _this$props2.analyticsDecorator;
108
+ if (analyticsDecorator) {
109
+ payload = analyticsDecorator(payload);
110
+ }
111
+ if (createAnalyticsEvent) {
112
+ createAnalyticsEvent(payload).fire(CHANNEL_ID);
113
+ }
114
+ });
115
+ _defineProperty(_this, "onTabChange", function (index) {
116
+ var subjectId = 'shareTab';
117
+ var shareContentType = _this.props.shareContentType;
118
+ if (index === 1) {
119
+ subjectId = 'shareToSlackTab';
120
+ }
121
+ _this.createAndFireEvent(shareTabClicked(subjectId, shareContentType));
122
+ _this.setState({
123
+ tabIndex: index
124
+ });
125
+ });
126
+ _defineProperty(_this, "onMenuItemChange", function (menuType) {
127
+ var subjectId = menuType === 'Slack' ? 'shareToSlackMenuItem' : 'shareMenuItem';
128
+ var shareContentType = _this.props.shareContentType;
129
+ _this.createAndFireEvent(shareMenuItemClicked(subjectId, shareContentType));
130
+ _this.setState({
131
+ isMenuItemSelected: true
132
+ });
133
+ });
134
+ _defineProperty(_this, "getFlags", function () {
135
+ var formatMessage = _this.props.intl.formatMessage;
136
+
137
+ // The reason for providing message property is that in jira,
138
+ // the Flag system takes only Message Descriptor as payload
139
+ // and formatMessage is called for every flag
140
+ // if the translation data is not provided, a translated default message
141
+ // will be displayed
142
+ return [{
143
+ appearance: 'success',
144
+ title: _objectSpread(_objectSpread({}, messages.shareSuccessMessage), {}, {
145
+ defaultMessage: formatMessage(messages.shareSuccessMessage, {
146
+ object: _this.props.shareContentType.toLowerCase()
147
+ })
148
+ }),
149
+ type: OBJECT_SHARED
150
+ }];
151
+ });
152
+ _defineProperty(_this, "setIsLoading", function (isLoading) {
153
+ _this.setState({
154
+ isLoading: isLoading
155
+ });
156
+ });
157
+ _defineProperty(_this, "focus", function () {
158
+ if (_this.containerRef.current) {
159
+ _this.containerRef.current.focus();
160
+ }
161
+ });
162
+ _defineProperty(_this, "handleKeyDown", function (event) {
163
+ var _this$state = _this.state,
164
+ isLoading = _this$state.isLoading,
165
+ isDialogOpen = _this$state.isDialogOpen;
166
+ var shouldCloseOnEscapePress = _this.props.shouldCloseOnEscapePress;
167
+ if (isLoading) {
168
+ event.stopPropagation();
169
+ _this.focus();
170
+ }
171
+ if (isDialogOpen) {
172
+ switch (event.key) {
173
+ case 'Esc':
174
+ case 'Escape':
175
+ // The @atlaskit/popup will capture the event and auto-close, we
176
+ // need to prevent that if the dialog is set to not close on `ESC`
177
+ if (!shouldCloseOnEscapePress) {
178
+ event.preventDefault();
179
+ event.stopPropagation();
180
+ // put the focus back onto the share dialog so that
181
+ // the user can press the escape key again to close the dialog
182
+ _this.focus();
183
+ return;
184
+ }
185
+ // The dialog will auto-close in @atlaskit/popup, we just need to fire
186
+ // the right events.
187
+ if (shouldCloseOnEscapePress) {
188
+ // This experience should be aborted in a scenario when a user closes the dialog before the shareClient.getConfig() call is finished
189
+ // It is a race condition between the `SUCCEEDED` case and the `ABORTED` case of this experience
190
+ // UFO experiences can only have one FINAL state so it doesn't matter if we call .abort() after the experience has succeeded and vice versa
191
+ renderShareDialogExp.abort();
192
+ _this.createAndFireEvent(cancelShare(_this.start));
193
+ _this.closeAndResetDialog();
194
+ }
195
+ }
196
+ }
197
+ });
198
+ _defineProperty(_this, "handleDialogOpen", function () {
199
+ _this.setState(function (state) {
200
+ return {
201
+ isDialogOpen: !state.isDialogOpen,
202
+ ignoreIntermediateState: false,
203
+ showIntegrationForm: false,
204
+ selectedIntegration: null
205
+ };
206
+ }, function () {
207
+ var _this$props3 = _this.props,
208
+ onDialogOpen = _this$props3.onDialogOpen,
209
+ isPublicLink = _this$props3.isPublicLink;
210
+ var isDialogOpen = _this.state.isDialogOpen;
211
+ if (isDialogOpen) {
212
+ _this.start = Date.now();
213
+ _this.createAndFireEvent(screenEvent({
214
+ isPublicLink: isPublicLink
215
+ }));
216
+ if (onDialogOpen) {
217
+ onDialogOpen();
218
+ }
219
+ _this.focus();
220
+ } else {
221
+ _this.handleCloseDialog();
222
+ }
223
+ });
224
+ });
225
+ _defineProperty(_this, "onTriggerClick", function () {
226
+ var onTriggerButtonClick = _this.props.onTriggerButtonClick;
227
+ _this.createAndFireEvent(shareTriggerButtonClicked());
228
+ _this.handleDialogOpen();
229
+ if (onTriggerButtonClick) {
230
+ onTriggerButtonClick();
231
+ }
232
+ });
233
+ _defineProperty(_this, "handleCloseDialog", function () {
234
+ if (_this.props.onDialogClose) {
235
+ _this.props.onDialogClose();
236
+ }
237
+
238
+ // This experience should be aborted in a scenario when a user closes the dialog before the shareClient.getConfig() call is finished
239
+ // It is a race condition between the `SUCCEEDED` case and the `ABORTED` case of this experience
240
+ // UFO experiences can only have one FINAL state so it doesn't matter if we call .abort() after the experience has succeeded and vice versa
241
+ renderShareDialogExp.abort();
242
+ _this.setState({
243
+ isDialogOpen: false,
244
+ showIntegrationForm: false,
245
+ selectedIntegration: null,
246
+ tabIndex: 0,
247
+ isMenuItemSelected: false
248
+ });
249
+ });
250
+ _defineProperty(_this, "handleShareSubmit", function (data) {
251
+ var _this$props4 = _this.props,
252
+ onShareSubmit = _this$props4.onShareSubmit,
253
+ shareContentType = _this$props4.shareContentType,
254
+ shareContentSubType = _this$props4.shareContentSubType,
255
+ shareContentId = _this$props4.shareContentId,
256
+ formShareOrigin = _this$props4.formShareOrigin,
257
+ showFlags = _this$props4.showFlags,
258
+ isPublicLink = _this$props4.isPublicLink;
259
+ if (!onShareSubmit) {
260
+ return;
261
+ }
262
+ shareSubmitExp.start();
263
+ _this.setState({
264
+ isSharing: true
265
+ });
266
+ _this.createAndFireEvent(formShareSubmitted({
267
+ start: _this.start,
268
+ data: data,
269
+ shareContentType: shareContentType,
270
+ shareOrigin: formShareOrigin,
271
+ isPublicLink: isPublicLink,
272
+ shareContentSubType: shareContentSubType,
273
+ shareContentId: shareContentId
274
+ }));
275
+ onShareSubmit(data).then(function () {
276
+ _this.closeAndResetDialog();
277
+ _this.setState({
278
+ isSharing: false
279
+ });
280
+ showFlags(_this.getFlags());
281
+ shareSubmitExp.success();
282
+ }).catch( /*#__PURE__*/function () {
283
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(err) {
284
+ var shareError;
285
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
286
+ while (1) switch (_context.prev = _context.next) {
287
+ case 0:
288
+ _context.next = 2;
289
+ return _this.generateShareError(err).catch(function (errorGenFailed) {
290
+ return {
291
+ message: err.message || errorGenFailed.message || 'Unknown error',
292
+ retryable: true
293
+ };
294
+ });
295
+ case 2:
296
+ shareError = _context.sent;
297
+ _this.setState({
298
+ isSharing: false,
299
+ shareError: shareError
300
+ });
301
+ isValidFailedExperience(shareSubmitExp, err);
302
+ case 5:
303
+ case "end":
304
+ return _context.stop();
305
+ }
306
+ }, _callee);
307
+ }));
308
+ return function (_x) {
309
+ return _ref.apply(this, arguments);
310
+ };
311
+ }());
312
+ });
313
+ _defineProperty(_this, "handleFormDismiss", function (data) {
314
+ _this.setState(function (_ref2) {
315
+ var ignoreIntermediateState = _ref2.ignoreIntermediateState;
316
+ return ignoreIntermediateState ? null : {
317
+ defaultValue: data
318
+ };
319
+ });
320
+ });
321
+ _defineProperty(_this, "calculatePopupOffset", function (_ref3) {
322
+ var isMenuItemSelected = _ref3.isMenuItemSelected,
323
+ dialogPlacement = _ref3.dialogPlacement;
324
+ if (isMenuItemSelected && dialogPlacement === 'bottom-end') {
325
+ return [-0.1, 8];
326
+ }
327
+ return [0, 8];
328
+ });
329
+ _defineProperty(_this, "handleCopyLink", function () {
330
+ var _this$props5 = _this.props,
331
+ copyLinkOrigin = _this$props5.copyLinkOrigin,
332
+ shareContentType = _this$props5.shareContentType,
333
+ shareContentSubType = _this$props5.shareContentSubType,
334
+ shareContentId = _this$props5.shareContentId,
335
+ isPublicLink = _this$props5.isPublicLink,
336
+ shareAri = _this$props5.shareAri;
337
+ _this.createAndFireEvent(copyLinkButtonClicked({
338
+ start: _this.start,
339
+ shareContentType: shareContentType,
340
+ shareOrigin: copyLinkOrigin,
341
+ isPublicLink: isPublicLink,
342
+ ari: shareAri,
343
+ shareContentSubType: shareContentSubType,
344
+ shareContentId: shareContentId
345
+ }));
346
+ });
347
+ _defineProperty(_this, "handleIntegrationClick", function (integration) {
348
+ _this.setState({
349
+ isUsingSplitButton: false,
350
+ isDialogOpen: true,
351
+ showIntegrationForm: true,
352
+ selectedIntegration: integration
353
+ });
354
+ });
355
+ _defineProperty(_this, "renderShareTriggerButton", function (triggerProps) {
356
+ var _this$state2 = _this.state,
357
+ isDialogOpen = _this$state2.isDialogOpen,
358
+ isUsingSplitButton = _this$state2.isUsingSplitButton;
359
+ var _this$props6 = _this.props,
360
+ formatMessage = _this$props6.intl.formatMessage,
361
+ isDisabled = _this$props6.isDisabled,
362
+ renderCustomTriggerButton = _this$props6.renderCustomTriggerButton,
363
+ triggerButtonIcon = _this$props6.triggerButtonIcon,
364
+ triggerButtonTooltipText = _this$props6.triggerButtonTooltipText,
365
+ triggerButtonTooltipPosition = _this$props6.triggerButtonTooltipPosition,
366
+ triggerButtonAppearance = _this$props6.triggerButtonAppearance,
367
+ triggerButtonStyle = _this$props6.triggerButtonStyle,
368
+ integrationMode = _this$props6.integrationMode,
369
+ shareIntegrations = _this$props6.shareIntegrations,
370
+ dialogZIndex = _this$props6.dialogZIndex,
371
+ dialogPlacement = _this$props6.dialogPlacement;
372
+ var button;
373
+ var ShareButtonIcon = triggerButtonIcon || IconShare;
374
+
375
+ // Render a custom or standard button.
376
+ if (renderCustomTriggerButton) {
377
+ var shareError = _this.state.shareError;
378
+ button = renderCustomTriggerButton({
379
+ error: shareError,
380
+ isDisabled: isDisabled,
381
+ isSelected: isDialogOpen,
382
+ onClick: _this.onTriggerClick
383
+ }, triggerProps);
384
+ } else {
385
+ button = /*#__PURE__*/React.createElement(ShareButton, {
386
+ appearance: triggerButtonAppearance,
387
+ text: triggerButtonStyle !== 'icon-only' ? /*#__PURE__*/React.createElement(FormattedMessage, messages.shareTriggerButtonText) : null,
388
+ "aria-label": formatMessage(messages.shareTriggerButtonText),
389
+ onClick: _this.onTriggerClick,
390
+ iconBefore: triggerButtonStyle !== 'text-only' ? /*#__PURE__*/React.createElement(ShareButtonIcon, {
391
+ label: ""
392
+ }) : undefined,
393
+ isSelected: isDialogOpen,
394
+ isDisabled: isDisabled,
395
+ ref: triggerProps.ref
396
+ // When we autoFocus the dialog, we want to autofocus the trigger as well, that way when the dialog is closed, the trigger is focused
397
+ ,
398
+ autoFocus: _this.props.isAutoOpenDialog
399
+ });
400
+ }
401
+
402
+ // If the button only shows the icon, wrap it in a tooltip containing the button text.
403
+ if (triggerButtonStyle === 'icon-only') {
404
+ button = /*#__PURE__*/React.createElement(Aktooltip, {
405
+ content: !isUsingSplitButton ? triggerButtonTooltipText || formatMessage(messages.shareTriggerButtonTooltipText) : null,
406
+ position: triggerButtonTooltipPosition,
407
+ hideTooltipOnClick: true
408
+ }, button);
409
+ }
410
+
411
+ // If there are any integrations, wrap the share button in a split button with integrations.
412
+ if (integrationMode === 'split' && shareIntegrations !== null && shareIntegrations !== void 0 && shareIntegrations.length) {
413
+ button = /*#__PURE__*/React.createElement(SplitButton, {
414
+ shareButton: button,
415
+ handleOpenSplitButton: _this.handleOpenSplitButton,
416
+ handleCloseSplitButton: _this.handleCloseSplitButton,
417
+ isUsingSplitButton: isUsingSplitButton,
418
+ triggerButtonAppearance: triggerButtonAppearance,
419
+ dialogZIndex: dialogZIndex,
420
+ dialogPlacement: dialogPlacement,
421
+ shareIntegrations: shareIntegrations,
422
+ onIntegrationClick: _this.handleIntegrationClick,
423
+ createAndFireEvent: _this.createAndFireEvent
424
+ });
425
+ }
426
+ return button;
427
+ });
428
+ _defineProperty(_this, "handleOpenSplitButton", function () {
429
+ _this.setState({
430
+ isUsingSplitButton: true
431
+ }, function () {
432
+ return _this.handleCloseDialog();
433
+ });
434
+ _this.createAndFireEvent(shareSplitButtonEvent());
435
+ });
436
+ _defineProperty(_this, "handleCloseSplitButton", function () {
437
+ _this.setState({
438
+ isUsingSplitButton: false
439
+ });
440
+ });
441
+ _defineProperty(_this, "handleOnUserSelectionChange", function (value) {
442
+ var onUserSelectionChange = _this.props.onUserSelectionChange;
443
+ _this.setState({
444
+ shareError: undefined
445
+ });
446
+ onUserSelectionChange === null || onUserSelectionChange === void 0 || onUserSelectionChange(value);
447
+ });
448
+ return _this;
449
+ }
450
+ _inherits(ShareDialogWithTriggerInternal, _React$PureComponent);
451
+ return _createClass(ShareDialogWithTriggerInternal, [{
452
+ key: "componentDidMount",
453
+ value: function componentDidMount() {
454
+ if (this.props.isAutoOpenDialog) {
455
+ this.handleDialogOpen();
456
+ }
457
+ }
458
+ }, {
459
+ key: "componentDidUpdate",
460
+ value: function componentDidUpdate(prevProps) {
461
+ if (this.props.isAutoOpenDialog !== prevProps.isAutoOpenDialog && this.props.isAutoOpenDialog) {
462
+ this.handleDialogOpen();
463
+ }
464
+ }
465
+ }, {
466
+ key: "componentWillUnmount",
467
+ value: function componentWillUnmount() {
468
+ if (this.props.isAutoOpenDialog && this.props.onDialogClose) {
469
+ this.props.onDialogClose();
470
+ }
471
+ }
472
+ }, {
473
+ key: "generateShareError",
474
+ value: function () {
475
+ var _generateShareError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(err) {
476
+ var _errorBody$messagesDe;
477
+ var errorBody, firstErrorFromBody;
478
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
479
+ while (1) switch (_context2.prev = _context2.next) {
480
+ case 0:
481
+ if (!err.body) {
482
+ _context2.next = 6;
483
+ break;
484
+ }
485
+ _context2.next = 3;
486
+ return err.body;
487
+ case 3:
488
+ _context2.t0 = _context2.sent;
489
+ _context2.next = 7;
490
+ break;
491
+ case 6:
492
+ _context2.t0 = {};
493
+ case 7:
494
+ errorBody = _context2.t0;
495
+ // We'll only try and deal with the first error, sorry
496
+ firstErrorFromBody = (_errorBody$messagesDe = errorBody.messagesDetails) === null || _errorBody$messagesDe === void 0 ? void 0 : _errorBody$messagesDe[0];
497
+ return _context2.abrupt("return", {
498
+ message: (firstErrorFromBody === null || firstErrorFromBody === void 0 ? void 0 : firstErrorFromBody.message) || err.message,
499
+ errorCode: firstErrorFromBody === null || firstErrorFromBody === void 0 ? void 0 : firstErrorFromBody.errorCode,
500
+ helpUrl: firstErrorFromBody === null || firstErrorFromBody === void 0 ? void 0 : firstErrorFromBody.helpUrl,
501
+ retryable: (firstErrorFromBody === null || firstErrorFromBody === void 0 ? void 0 : firstErrorFromBody.errorCode) === undefined
502
+ });
503
+ case 10:
504
+ case "end":
505
+ return _context2.stop();
506
+ }
507
+ }, _callee2);
508
+ }));
509
+ function generateShareError(_x2) {
510
+ return _generateShareError.apply(this, arguments);
511
+ }
512
+ return generateShareError;
513
+ }()
514
+ }, {
515
+ key: "render",
516
+ value: function render() {
517
+ var _this2 = this;
518
+ var _this$state3 = this.state,
519
+ isDialogOpen = _this$state3.isDialogOpen,
520
+ isSharing = _this$state3.isSharing,
521
+ shareError = _this$state3.shareError,
522
+ defaultValue = _this$state3.defaultValue,
523
+ showIntegrationForm = _this$state3.showIntegrationForm,
524
+ selectedIntegration = _this$state3.selectedIntegration,
525
+ isMenuItemSelected = _this$state3.isMenuItemSelected;
526
+ var _this$props7 = this.props,
527
+ copyLink = _this$props7.copyLink,
528
+ dialogPlacement = _this$props7.dialogPlacement,
529
+ config = _this$props7.config,
530
+ isFetchingConfig = _this$props7.isFetchingConfig,
531
+ loadUserOptions = _this$props7.loadUserOptions,
532
+ shareFormTitle = _this$props7.shareFormTitle,
533
+ shareFormHelperMessage = _this$props7.shareFormHelperMessage,
534
+ bottomMessage = _this$props7.bottomMessage,
535
+ submitButtonLabel = _this$props7.submitButtonLabel,
536
+ product = _this$props7.product,
537
+ productAttributes = _this$props7.productAttributes,
538
+ customFooter = _this$props7.customFooter,
539
+ enableSmartUserPicker = _this$props7.enableSmartUserPicker,
540
+ loggedInAccountId = _this$props7.loggedInAccountId,
541
+ cloudId = _this$props7.cloudId,
542
+ orgId = _this$props7.orgId,
543
+ shareFieldsFooter = _this$props7.shareFieldsFooter,
544
+ dialogZIndex = _this$props7.dialogZIndex,
545
+ isPublicLink = _this$props7.isPublicLink,
546
+ tabIndex = _this$props7.tabIndex,
547
+ copyTooltipText = _this$props7.copyTooltipText,
548
+ integrationMode = _this$props7.integrationMode,
549
+ shareIntegrations = _this$props7.shareIntegrations,
550
+ additionalTabs = _this$props7.additionalTabs,
551
+ builtInTabContentWidth = _this$props7.builtInTabContentWidth,
552
+ isBrowseUsersDisabled = _this$props7.isBrowseUsersDisabled,
553
+ userPickerOptions = _this$props7.userPickerOptions,
554
+ isSubmitShareDisabled = _this$props7.isSubmitShareDisabled;
555
+ var footer = resolveShareFooter(integrationMode, this.state.tabIndex, customFooter);
556
+
557
+ // for performance purposes, we may want to have a loadable content i.e. ShareForm
558
+ return /*#__PURE__*/React.createElement(Box, {
559
+ xcss: cx(styles.shareButtonWrapperStyles, typeof tabIndex !== 'undefined' && tabIndex >= 0 && styles.outlineNone),
560
+ tabIndex: tabIndex,
561
+ onKeyDown: this.handleKeyDown
562
+ }, /*#__PURE__*/React.createElement(Popup, {
563
+ content: function content() {
564
+ return /*#__PURE__*/React.createElement("div", {
565
+ ref: _this2.containerRef
566
+ }, /*#__PURE__*/React.createElement(LazyShareFormLazy, {
567
+ Content: selectedIntegration && selectedIntegration.Content,
568
+ selectedIntegration: selectedIntegration,
569
+ copyLink: copyLink,
570
+ showIntegrationForm: showIntegrationForm,
571
+ bottomMessage: bottomMessage,
572
+ customFooter: footer,
573
+ loadOptions: loadUserOptions,
574
+ isSharing: isSharing,
575
+ shareFormTitle: shareFormTitle,
576
+ showTitle: integrationMode !== 'tabs' || !shareIntegrations || !shareIntegrations.length,
577
+ shareFormHelperMessage: shareFormHelperMessage,
578
+ shareError: shareError,
579
+ defaultValue: defaultValue,
580
+ config: config,
581
+ isFetchingConfig: isFetchingConfig,
582
+ setIsLoading: _this2.setIsLoading,
583
+ submitButtonLabel: submitButtonLabel,
584
+ product: product,
585
+ productAttributes: productAttributes,
586
+ enableSmartUserPicker: enableSmartUserPicker,
587
+ loggedInAccountId: loggedInAccountId,
588
+ cloudId: cloudId,
589
+ orgId: orgId,
590
+ onUserSelectionChange: _this2.handleOnUserSelectionChange,
591
+ shareFieldsFooter: shareFieldsFooter,
592
+ isPublicLink: isPublicLink,
593
+ copyTooltipText: copyTooltipText,
594
+ integrationMode: integrationMode,
595
+ shareIntegrations: shareIntegrations,
596
+ additionalTabs: additionalTabs,
597
+ builtInTabContentWidth: builtInTabContentWidth,
598
+ isMenuItemSelected: isMenuItemSelected,
599
+ isSubmitShareDisabled: isSubmitShareDisabled
600
+ // actions
601
+ ,
602
+ onLinkCopy: _this2.handleCopyLink,
603
+ onSubmit: _this2.handleShareSubmit,
604
+ onDismiss: _this2.handleFormDismiss,
605
+ onDialogClose: _this2.handleCloseDialog,
606
+ onTabChange: _this2.onTabChange,
607
+ onMenuItemChange: _this2.onMenuItemChange
608
+ //ref
609
+ ,
610
+ selectPortalRef: _this2.selectPortalRef,
611
+ isBrowseUsersDisabled: isBrowseUsersDisabled,
612
+ userPickerOptions: userPickerOptions
613
+ }));
614
+ },
615
+ isOpen: isDialogOpen,
616
+ onClose: this.handleCloseDialog,
617
+ placement: dialogPlacement,
618
+ trigger: this.renderShareTriggerButton,
619
+ zIndex: dialogZIndex,
620
+ label: this.props.intl.formatMessage(messages.sharePopupLabel),
621
+ role: "dialog"
622
+ // TODO: remove after https://hello.atlassian.net/wiki/x/SoEGzQ experiment is finished
623
+ ,
624
+ offset: this.calculatePopupOffset({
625
+ isMenuItemSelected: isMenuItemSelected,
626
+ dialogPlacement: dialogPlacement
627
+ }),
628
+ shouldRenderToParent: fg('enable-appropriate-reading-order-in-share-dialog')
629
+ }), /*#__PURE__*/React.createElement(Portal, {
630
+ zIndex: generateSelectZIndex(dialogZIndex)
631
+ }, /*#__PURE__*/React.createElement("div", {
632
+ ref: this.selectPortalRef
633
+ })));
634
+ }
635
+ }]);
636
+ }(React.PureComponent);
637
+ _defineProperty(ShareDialogWithTriggerInternal, "defaultProps", {
638
+ isDisabled: false,
639
+ dialogPlacement: 'bottom-end',
640
+ shouldCloseOnEscapePress: true,
641
+ triggerButtonAppearance: 'subtle',
642
+ triggerButtonStyle: 'icon-only',
643
+ triggerButtonTooltipPosition: 'top',
644
+ dialogZIndex: layers.modal()
645
+ });
646
+ export var ShareDialogWithTrigger = withAnalyticsEvents()(injectIntl(ShareDialogWithTriggerInternal));
@@ -0,0 +1,21 @@
1
+ ._11c81vlj{font:var(--ds-font-body-small,normal 400 11px/1pc ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,system-ui,"Helvetica Neue",sans-serif)}
2
+ ._2rkoglpi{border-radius:var(--ds-border-radius,4px)}
3
+ ._18zrutpp{padding-inline:var(--ds-space-150,9pt)}
4
+ ._195g10v4{margin-inline:var(--ds-space-negative-300,-24px)}
5
+ ._1moux0bf{margin-block:var(--ds-space-negative-100,-8px)}
6
+ ._1rjcze3t{padding-block:var(--ds-space-0,0)}
7
+ ._18u01wug{margin-left:auto}
8
+ ._19pku2gc{margin-top:var(--ds-space-100,8px)}
9
+ ._1bah1y6m{justify-content:flex-start}
10
+ ._1bsb1osq{width:100%}
11
+ ._1bsb1w81{width:150px}
12
+ ._1e0c1txw{display:flex}
13
+ ._1wpz1h6o{align-self:center}
14
+ ._2hwx1b66{margin-right:var(--ds-space-050,4px)}
15
+ ._4cvr1h6o{align-items:center}
16
+ ._4cvr1y6m{align-items:flex-start}
17
+ ._otyr196n{margin-bottom:var(--ds-space-negative-075,-6px)}
18
+ ._otyrpxbi{margin-bottom:var(--ds-space-200,1pc)}
19
+ ._otyrutpp{margin-bottom:var(--ds-space-150,9pt)}
20
+ ._syaz1fxt{color:var(--ds-text,#172b4d)}
21
+ ._syaz1n3s{color:var(--ds-text-subtle,#5e6c84)}