@atlaskit/link-create 2.0.0 → 2.2.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 (129) hide show
  1. package/CHANGELOG.md +352 -337
  2. package/dist/cjs/common/constants.js +8 -2
  3. package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -6
  4. package/dist/cjs/{ui/link-create → common/ui}/edit-modal/index.js +4 -8
  5. package/dist/cjs/{ui/link-create → common/ui}/error-boundary/index.js +1 -1
  6. package/dist/cjs/{controllers → common/ui}/experience-tracker/index.js +3 -3
  7. package/dist/cjs/common/ui/link-create-content/index.js +21 -0
  8. package/dist/cjs/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
  9. package/dist/cjs/controllers/callback-context/main.js +1 -1
  10. package/dist/cjs/index.js +6 -0
  11. package/dist/cjs/ui/create-form/main.js +1 -1
  12. package/dist/cjs/ui/create-form/user-picker/index.js +12 -0
  13. package/dist/cjs/ui/create-form/user-picker/main.js +59 -0
  14. package/dist/cjs/ui/create-form/user-picker/types.js +5 -0
  15. package/dist/cjs/ui/index.js +19 -5
  16. package/dist/cjs/ui/{main.js → inline-create/index.js} +11 -17
  17. package/dist/cjs/ui/inline-create/main.js +125 -0
  18. package/dist/cjs/ui/modal-create/index.js +38 -0
  19. package/dist/cjs/ui/{link-create → modal-create}/main.js +36 -39
  20. package/dist/es2019/common/constants.js +7 -1
  21. package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -7
  22. package/dist/es2019/{ui/link-create → common/ui}/edit-modal/index.js +4 -10
  23. package/dist/es2019/{ui/link-create → common/ui}/error-boundary/index.js +1 -1
  24. package/dist/es2019/{controllers → common/ui}/experience-tracker/index.js +3 -3
  25. package/dist/es2019/common/ui/link-create-content/index.js +11 -0
  26. package/dist/es2019/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
  27. package/dist/es2019/controllers/callback-context/main.js +1 -1
  28. package/dist/es2019/index.js +4 -1
  29. package/dist/es2019/ui/create-form/main.js +1 -1
  30. package/dist/es2019/ui/create-form/user-picker/index.js +1 -0
  31. package/dist/es2019/ui/create-form/user-picker/main.js +48 -0
  32. package/dist/es2019/ui/create-form/user-picker/types.js +1 -0
  33. package/dist/es2019/ui/index.js +4 -2
  34. package/dist/es2019/ui/inline-create/index.js +30 -0
  35. package/dist/es2019/ui/inline-create/main.js +100 -0
  36. package/dist/es2019/ui/{main.js → modal-create/index.js} +8 -14
  37. package/dist/es2019/ui/{link-create → modal-create}/main.js +19 -19
  38. package/dist/esm/common/constants.js +7 -1
  39. package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -6
  40. package/dist/esm/{ui/link-create → common/ui}/edit-modal/index.js +4 -8
  41. package/dist/esm/{ui/link-create → common/ui}/error-boundary/index.js +1 -1
  42. package/dist/esm/{controllers → common/ui}/experience-tracker/index.js +3 -3
  43. package/dist/esm/common/ui/link-create-content/index.js +12 -0
  44. package/dist/esm/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
  45. package/dist/esm/controllers/callback-context/main.js +1 -1
  46. package/dist/esm/index.js +4 -1
  47. package/dist/esm/ui/create-form/main.js +1 -1
  48. package/dist/esm/ui/create-form/user-picker/index.js +1 -0
  49. package/dist/esm/ui/create-form/user-picker/main.js +51 -0
  50. package/dist/esm/ui/create-form/user-picker/types.js +1 -0
  51. package/dist/esm/ui/index.js +4 -2
  52. package/dist/esm/ui/inline-create/index.js +30 -0
  53. package/dist/esm/ui/inline-create/main.js +119 -0
  54. package/dist/esm/ui/{main.js → modal-create/index.js} +8 -14
  55. package/dist/esm/ui/{link-create → modal-create}/main.js +38 -41
  56. package/dist/types/common/constants.d.ts +2 -0
  57. package/dist/types/common/ui/Button/index.d.ts +1 -1
  58. package/dist/types/common/ui/confirm-dismiss-dialog/main.d.ts +7 -0
  59. package/dist/types/common/ui/edit-modal/index.d.ts +11 -0
  60. package/dist/types/{ui/link-create → common/ui}/error-boundary/index.d.ts +1 -1
  61. package/dist/types/common/ui/link-create-content/index.d.ts +8 -0
  62. package/dist/types/common/utils/analytics/index.d.ts +1 -1
  63. package/dist/types/controllers/exit-warning-modal-context/index.d.ts +1 -1
  64. package/dist/types/controllers/form-context/index.d.ts +1 -1
  65. package/dist/types/index.d.ts +2 -2
  66. package/dist/types/ui/create-form/form-spy/index.d.ts +1 -1
  67. package/dist/types/ui/create-form/user-picker/index.d.ts +1 -0
  68. package/dist/types/ui/create-form/user-picker/main.d.ts +8 -0
  69. package/dist/types/ui/create-form/user-picker/types.d.ts +25 -0
  70. package/dist/types/ui/index.d.ts +3 -1
  71. package/dist/types/ui/inline-create/index.d.ts +5 -0
  72. package/dist/types/ui/inline-create/main.d.ts +5 -0
  73. package/dist/types/ui/modal-create/index.d.ts +5 -0
  74. package/dist/{types-ts4.5/ui/link-create → types/ui/modal-create}/main.d.ts +1 -1
  75. package/dist/types-ts4.5/common/constants.d.ts +2 -0
  76. package/dist/types-ts4.5/common/ui/Button/index.d.ts +1 -1
  77. package/dist/types-ts4.5/common/ui/confirm-dismiss-dialog/main.d.ts +7 -0
  78. package/dist/types-ts4.5/common/ui/edit-modal/index.d.ts +11 -0
  79. package/dist/types-ts4.5/{ui/link-create → common/ui}/error-boundary/index.d.ts +1 -1
  80. package/dist/types-ts4.5/common/ui/link-create-content/index.d.ts +8 -0
  81. package/dist/types-ts4.5/common/utils/analytics/index.d.ts +1 -1
  82. package/dist/types-ts4.5/controllers/exit-warning-modal-context/index.d.ts +1 -1
  83. package/dist/types-ts4.5/controllers/form-context/index.d.ts +1 -1
  84. package/dist/types-ts4.5/index.d.ts +2 -2
  85. package/dist/types-ts4.5/ui/create-form/form-spy/index.d.ts +1 -1
  86. package/dist/types-ts4.5/ui/create-form/user-picker/index.d.ts +1 -0
  87. package/dist/types-ts4.5/ui/create-form/user-picker/main.d.ts +8 -0
  88. package/dist/types-ts4.5/ui/create-form/user-picker/types.d.ts +25 -0
  89. package/dist/types-ts4.5/ui/index.d.ts +3 -1
  90. package/dist/types-ts4.5/ui/{main.d.ts → inline-create/index.d.ts} +1 -3
  91. package/dist/types-ts4.5/ui/inline-create/main.d.ts +5 -0
  92. package/dist/{types/ui/main.d.ts → types-ts4.5/ui/modal-create/index.d.ts} +1 -3
  93. package/dist/{types/ui/link-create → types-ts4.5/ui/modal-create}/main.d.ts +1 -1
  94. package/example-helpers/mock-disclaimer.tsx +11 -11
  95. package/example-helpers/mock-plugin-form.tsx +71 -74
  96. package/package.json +6 -7
  97. package/dist/cjs/ui/link-create/index.js +0 -13
  98. package/dist/es2019/ui/link-create/index.js +0 -1
  99. package/dist/esm/ui/link-create/index.js +0 -1
  100. package/dist/types/ui/link-create/confirm-dismiss-dialog/main.d.ts +0 -6
  101. package/dist/types/ui/link-create/edit-modal/index.d.ts +0 -8
  102. package/dist/types/ui/link-create/index.d.ts +0 -1
  103. package/dist/types-ts4.5/ui/link-create/confirm-dismiss-dialog/main.d.ts +0 -6
  104. package/dist/types-ts4.5/ui/link-create/edit-modal/index.d.ts +0 -8
  105. package/dist/types-ts4.5/ui/link-create/index.d.ts +0 -1
  106. /package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
  107. /package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
  108. /package/dist/cjs/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
  109. /package/dist/cjs/ui/{link-create → modal-create}/messages.js +0 -0
  110. /package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
  111. /package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
  112. /package/dist/es2019/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
  113. /package/dist/es2019/ui/{link-create → modal-create}/messages.js +0 -0
  114. /package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
  115. /package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
  116. /package/dist/esm/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
  117. /package/dist/esm/ui/{link-create → modal-create}/messages.js +0 -0
  118. /package/dist/types/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.d.ts +0 -0
  119. /package/dist/types/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.d.ts +0 -0
  120. /package/dist/types/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.d.ts +0 -0
  121. /package/dist/types/{controllers → common/ui}/experience-tracker/index.d.ts +0 -0
  122. /package/dist/types/{ui/link-create → common/ui}/modal-hero/index.d.ts +0 -0
  123. /package/dist/types/ui/{link-create → modal-create}/messages.d.ts +0 -0
  124. /package/dist/types-ts4.5/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.d.ts +0 -0
  125. /package/dist/types-ts4.5/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.d.ts +0 -0
  126. /package/dist/types-ts4.5/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.d.ts +0 -0
  127. /package/dist/types-ts4.5/{controllers → common/ui}/experience-tracker/index.d.ts +0 -0
  128. /package/dist/types-ts4.5/{ui/link-create → common/ui}/modal-hero/index.d.ts +0 -0
  129. /package/dist/types-ts4.5/ui/{link-create → modal-create}/messages.d.ts +0 -0
@@ -3,7 +3,7 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../../../common/constants';
4
4
  import { ErrorBoundaryUI } from '../../../common/ui/error-boundary-ui';
5
5
  import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
6
- import { useExperience } from '../../../controllers/experience-tracker';
6
+ import { useExperience } from '../experience-tracker';
7
7
  import { BaseErrorBoundary } from './error-boundary-base';
8
8
  export var ErrorBoundary = function ErrorBoundary(_ref) {
9
9
  var children = _ref.children,
@@ -4,9 +4,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import React, { createContext, useContext, useMemo, useRef } from 'react';
5
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
6
6
  import { captureException } from '@atlaskit/linking-common/sentry';
7
- import { ANALYTICS_CHANNEL } from '../../common/constants';
8
- import createEventPayload from '../../common/utils/analytics/analytics.codegen';
9
- import { getErrorType, getNetworkFields } from '../../common/utils/errors';
7
+ import { ANALYTICS_CHANNEL } from '../../constants';
8
+ import createEventPayload from '../../utils/analytics/analytics.codegen';
9
+ import { getErrorType, getNetworkFields } from '../../utils/errors';
10
10
  var ExperienceContext = /*#__PURE__*/createContext({
11
11
  success: function success() {},
12
12
  failure: function failure() {}
@@ -0,0 +1,12 @@
1
+ import React, { Fragment } from 'react';
2
+ export var LinkCreateContent = function LinkCreateContent(_ref) {
3
+ var plugins = _ref.plugins,
4
+ entityKey = _ref.entityKey;
5
+ var chosenOne = plugins.find(function (plugin) {
6
+ return plugin.key === entityKey;
7
+ });
8
+ if (!chosenOne) {
9
+ throw new Error('Make sure you specified a valid entityKey');
10
+ }
11
+ return /*#__PURE__*/React.createElement(Fragment, null, chosenOne.form);
12
+ };
@@ -1,8 +1,6 @@
1
1
  import React, { Fragment } from 'react';
2
2
  import { Stack } from '@atlaskit/primitives';
3
-
4
- // eslint-disable-next-line @atlassian/tangerine/import/no-parent-imports
5
- import { ErrorBoundary } from '../error-boundary';
3
+ import { ErrorBoundary } from '../../../common/ui/error-boundary';
6
4
  var ErrorComponent = function ErrorComponent() {
7
5
  // when there's an error, render nothing but report the issue
8
6
  return /*#__PURE__*/React.createElement(Fragment, null, null);
@@ -6,9 +6,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import React, { useContext, useMemo } from 'react';
7
7
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
8
8
  import { ANALYTICS_CHANNEL } from '../../common/constants';
9
+ import { useExperience } from '../../common/ui/experience-tracker';
9
10
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
10
11
  import { getErrorType } from '../../common/utils/errors';
11
- import { useExperience } from '../experience-tracker';
12
12
  var LinkCreateCallbackContext = /*#__PURE__*/React.createContext({});
13
13
  var LinkCreateCallbackProvider = function LinkCreateCallbackProvider(_ref) {
14
14
  var children = _ref.children,
package/dist/esm/index.js CHANGED
@@ -1,3 +1,6 @@
1
- export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy } from './ui/index';
1
+ export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy,
2
+ // todo: EDM-10077 - export this once inline-create is tested/ready
3
+ //InlineCreate,
4
+ UserPicker } from './ui/index';
2
5
  export { useLinkCreateCallback, LinkCreateCallbackProvider } from './controllers/callback-context';
3
6
  export { FORM_ERROR } from 'final-form';
@@ -150,7 +150,7 @@ export var CreateForm = function CreateForm(_ref) {
150
150
  }
151
151
  }), jsx("p", {
152
152
  "aria-hidden": "true"
153
- }, intl.formatMessage(messages.requiredFieldInstruction), ' ', jsx(RequiredAsterisk, null)), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter
153
+ }, intl.formatMessage(messages.requiredFieldInstruction), " ", jsx(RequiredAsterisk, null)), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter
154
154
  /**
155
155
  * We will prefer to render the error message connected to
156
156
  * react final form state (submitError) otherwise we can
@@ -0,0 +1 @@
1
+ export { UserPicker } from './main';
@@ -0,0 +1,51 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ var _excluded = ["fieldId"];
3
+ /** @jsx jsx */
4
+ import { jsx } from '@emotion/react';
5
+ import SmartUserPicker from '@atlaskit/smart-user-picker';
6
+ import { CreateField } from '../../../controllers/create-field';
7
+ export var TEST_ID = 'link-create-user-picker';
8
+ var DEFAULT_DEBOUNCE_TIME = 400;
9
+ var UserPickerWidth = "100%";
10
+
11
+ /**
12
+ * A user picker utilising the SmartUserPicker.
13
+ */
14
+
15
+ export function UserPicker(_ref) {
16
+ var productKey = _ref.productKey,
17
+ siteId = _ref.siteId,
18
+ name = _ref.name,
19
+ label = _ref.label,
20
+ placeholder = _ref.placeholder,
21
+ validators = _ref.validators,
22
+ _ref$testId = _ref.testId,
23
+ testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
24
+ defaultValue = _ref.defaultValue;
25
+ return jsx(CreateField, {
26
+ name: name,
27
+ label: label,
28
+ isRequired: true,
29
+ testId: testId,
30
+ validators: validators
31
+ }, function (_ref2) {
32
+ var fieldId = _ref2.fieldId,
33
+ fieldProps = _objectWithoutProperties(_ref2, _excluded);
34
+ return jsx(SmartUserPicker, {
35
+ defaultValue: defaultValue,
36
+ placeholder: placeholder,
37
+ onChange: function onChange(value) {
38
+ return fieldProps.onChange(value);
39
+ },
40
+ subtle: true,
41
+ isMulti: false,
42
+ productKey: productKey,
43
+ siteId: siteId,
44
+ fieldId: fieldId,
45
+ debounceTime: DEFAULT_DEBOUNCE_TIME,
46
+ prefetch: true,
47
+ isClearable: false,
48
+ width: UserPickerWidth
49
+ });
50
+ });
51
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,9 @@
1
- export { default } from './main';
1
+ export { default } from './modal-create';
2
+ export { default as InlineCreate } from './inline-create';
2
3
  export { TextField } from './create-form/textfield';
3
4
  export { CreateForm } from './create-form/main';
4
5
  export { CreateFormLoader } from './create-form/form-loader';
5
6
  export { Select } from './create-form/select';
6
7
  export { AsyncSelect } from './create-form/async-select';
7
- export { FormSpy } from './create-form/form-spy';
8
+ export { FormSpy } from './create-form/form-spy';
9
+ export { UserPicker } from './create-form/user-picker';
@@ -0,0 +1,30 @@
1
+ /** @jsx jsx */
2
+ import { memo } from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ import { AnalyticsContext } from '@atlaskit/analytics-next';
5
+ import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
6
+ import { PACKAGE_DATA } from '../../common/constants';
7
+ import { ErrorBoundary } from '../../common/ui/error-boundary';
8
+ import { ErrorBoundaryModal } from '../../common/ui/error-boundary-modal';
9
+ import { Experience } from '../../common/ui/experience-tracker';
10
+ import { withLinkCreateAnalyticsContext } from '../../common/utils/analytics';
11
+ import { fetchMessagesForLocale } from '../../common/utils/locale/fetch-messages-for-locale';
12
+ import i18nEN from '../../i18n/en';
13
+ import InlineCreate from './main';
14
+ var LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(function (props) {
15
+ return jsx(Experience, null, jsx(ErrorBoundary, {
16
+ errorComponent: jsx(ErrorBoundaryModal, {
17
+ active: props.active,
18
+ onClose: props.onCancel
19
+ })
20
+ }, jsx(InlineCreate, props)));
21
+ }));
22
+ var ComposedLinkCreate = /*#__PURE__*/memo(function (props) {
23
+ return jsx(AnalyticsContext, {
24
+ data: PACKAGE_DATA
25
+ }, jsx(IntlMessagesProvider, {
26
+ defaultMessages: i18nEN,
27
+ loaderFn: fetchMessagesForLocale
28
+ }, jsx(LinkCreateWithAnalyticsContext, props)));
29
+ });
30
+ export default ComposedLinkCreate;
@@ -0,0 +1,119 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ /** @jsx jsx */
6
+ import { useCallback, useState } from 'react';
7
+ import { jsx } from '@emotion/react';
8
+ import { Box } from '@atlaskit/primitives';
9
+ import { ConfirmDismissDialog } from '../../common/ui/confirm-dismiss-dialog';
10
+ import { EditModal } from '../../common/ui/edit-modal';
11
+ import { ErrorBoundary } from '../../common/ui/error-boundary';
12
+ import { LinkCreateContent } from '../../common/ui/link-create-content';
13
+ import { LinkCreateCallbackProvider
14
+ // useLinkCreateCallback,
15
+ } from '../../controllers/callback-context';
16
+ import { EditPostCreateModalProvider, useEditPostCreateModal } from '../../controllers/edit-post-create-context';
17
+ import { ExitWarningModalProvider, useExitWarningModal } from '../../controllers/exit-warning-modal-context';
18
+ import { FormContextProvider } from '../../controllers/form-context';
19
+ import { LinkCreatePluginsProvider, useLinkCreatePlugins } from '../../controllers/plugin-context';
20
+ export var TEST_ID = 'link-create';
21
+ // todo: EDM-10075 trigger the screen.viewed_linkCreateScreen event when inline-create is mounted
22
+ // const SCREEN_ID = 'linkCreateScreen';
23
+
24
+ var InlineCreateContent = function InlineCreateContent(_ref) {
25
+ var onCreate = _ref.onCreate,
26
+ onFailure = _ref.onFailure,
27
+ onCancel = _ref.onCancel,
28
+ onComplete = _ref.onComplete,
29
+ plugins = _ref.plugins,
30
+ entityKey = _ref.entityKey,
31
+ testId = _ref.testId;
32
+ var _useExitWarningModal = useExitWarningModal(),
33
+ getShouldShowWarning = _useExitWarningModal.getShouldShowWarning;
34
+ var _useState = useState(false),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ showExitWarning = _useState2[0],
37
+ setShowExitWarning = _useState2[1];
38
+ var _useEditPostCreateMod = useEditPostCreateModal(),
39
+ editViewPayload = _useEditPostCreateMod.editViewPayload;
40
+ var _useLinkCreatePlugins = useLinkCreatePlugins(),
41
+ activePlugin = _useLinkCreatePlugins.activePlugin;
42
+ var handleCancel = useCallback(function () {
43
+ if (getShouldShowWarning() && !showExitWarning) {
44
+ setShowExitWarning(true);
45
+ return;
46
+ }
47
+ onCancel === null || onCancel === void 0 || onCancel();
48
+ }, [onCancel, getShouldShowWarning, showExitWarning]);
49
+ var handleCloseExitWarning = useCallback(function () {
50
+ return setShowExitWarning(false);
51
+ }, []);
52
+ return jsx(LinkCreateCallbackProvider, {
53
+ onCreate: onCreate,
54
+ onFailure: onFailure,
55
+ onCancel: handleCancel
56
+ }, jsx(ErrorBoundary, null, jsx(Box, {
57
+ testId: testId
58
+ }, jsx(LinkCreateContent, {
59
+ plugins: plugins,
60
+ entityKey: entityKey
61
+ }))), onComplete && jsx(EditModal, {
62
+ onClose: onComplete,
63
+ editViewPayload: editViewPayload,
64
+ activePlugin: activePlugin
65
+ }), jsx(ConfirmDismissDialog, {
66
+ active: showExitWarning,
67
+ onClose: handleCloseExitWarning,
68
+ onCancel: onCancel
69
+ }));
70
+ };
71
+ var InlineCreate = function InlineCreate(props) {
72
+ return jsx(LinkCreatePluginsProvider, {
73
+ plugins: props.plugins,
74
+ entityKey: props.entityKey
75
+ }, function (pluginsProvider) {
76
+ return jsx(EditPostCreateModalProvider, {
77
+ active: true
78
+ }, function (_ref2) {
79
+ var _pluginsProvider$acti;
80
+ var setEditViewPayload = _ref2.setEditViewPayload,
81
+ shouldActivateEditView = _ref2.shouldActivateEditView,
82
+ enableEditView = _ref2.enableEditView;
83
+ return jsx(FormContextProvider, {
84
+ enableEditView: pluginsProvider !== null && pluginsProvider !== void 0 && (_pluginsProvider$acti = pluginsProvider.activePlugin) !== null && _pluginsProvider$acti !== void 0 && _pluginsProvider$acti.editView && props !== null && props !== void 0 && props.onComplete ? enableEditView : undefined
85
+ }, jsx(ExitWarningModalProvider, null, jsx(InlineCreateContent, _extends({}, props, {
86
+ onCreate: ( /*#__PURE__*/function () {
87
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload) {
88
+ var _props$onCreate;
89
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
90
+ while (1) switch (_context.prev = _context.next) {
91
+ case 0:
92
+ _context.next = 2;
93
+ return (_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload);
94
+ case 2:
95
+ // if onComplete exists then there is an edit flow
96
+ if (props.onComplete) {
97
+ if (shouldActivateEditView()) {
98
+ //edit button is pressed
99
+ setEditViewPayload(payload);
100
+ } else {
101
+ //create button is pressed
102
+ props.onComplete();
103
+ }
104
+ }
105
+ case 3:
106
+ case "end":
107
+ return _context.stop();
108
+ }
109
+ }, _callee);
110
+ }));
111
+ return function (_x) {
112
+ return _ref3.apply(this, arguments);
113
+ };
114
+ }())
115
+ }))));
116
+ });
117
+ });
118
+ };
119
+ export default InlineCreate;
@@ -3,14 +3,14 @@ import { memo } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import { AnalyticsContext } from '@atlaskit/analytics-next';
5
5
  import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
6
- import { COMPONENT_NAME } from '../common/constants';
7
- import { ErrorBoundaryModal } from '../common/ui/error-boundary-modal';
8
- import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
9
- import { fetchMessagesForLocale } from '../common/utils/locale/fetch-messages-for-locale';
10
- import { Experience } from '../controllers/experience-tracker';
11
- import i18nEN from '../i18n/en';
12
- import LinkCreate from './link-create';
13
- import { ErrorBoundary } from './link-create/error-boundary';
6
+ import { PACKAGE_DATA } from '../../common/constants';
7
+ import { ErrorBoundary } from '../../common/ui/error-boundary';
8
+ import { ErrorBoundaryModal } from '../../common/ui/error-boundary-modal';
9
+ import { Experience } from '../../common/ui/experience-tracker';
10
+ import { withLinkCreateAnalyticsContext } from '../../common/utils/analytics';
11
+ import { fetchMessagesForLocale } from '../../common/utils/locale/fetch-messages-for-locale';
12
+ import i18nEN from '../../i18n/en';
13
+ import LinkCreate from './main';
14
14
  var LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(function (props) {
15
15
  return jsx(Experience, null, jsx(ErrorBoundary, {
16
16
  errorComponent: jsx(ErrorBoundaryModal, {
@@ -19,12 +19,6 @@ var LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__
19
19
  })
20
20
  }, jsx(LinkCreate, props)));
21
21
  }));
22
- export var PACKAGE_DATA = {
23
- packageName: "@atlaskit/link-create" || '',
24
- packageVersion: "2.0.0" || '',
25
- component: COMPONENT_NAME,
26
- componentName: COMPONENT_NAME
27
- };
28
22
  var ComposedLinkCreate = /*#__PURE__*/memo(function (props) {
29
23
  return jsx(AnalyticsContext, {
30
24
  data: PACKAGE_DATA
@@ -3,50 +3,40 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  /** @jsx jsx */
6
- import { Fragment, useCallback, useLayoutEffect, useRef, useState } from 'react';
6
+ import { useCallback, useLayoutEffect, useRef, useState } from 'react';
7
7
  import { jsx } from '@emotion/react';
8
8
  import { useIntl } from 'react-intl-next';
9
9
  import { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
10
10
  import { Box } from '@atlaskit/primitives';
11
11
  import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
12
+ import { ConfirmDismissDialog } from '../../common/ui/confirm-dismiss-dialog';
13
+ import { EditModal } from '../../common/ui/edit-modal';
14
+ import { ErrorBoundary } from '../../common/ui/error-boundary';
15
+ import { LinkCreateContent } from '../../common/ui/link-create-content';
16
+ import { ModalHero } from '../../common/ui/modal-hero';
12
17
  import { Modal } from '../../common/ui/ModalDialog';
13
18
  import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
14
- import { EditPostCreateModalProvider } from '../../controllers/edit-post-create-context';
19
+ import { EditPostCreateModalProvider, useEditPostCreateModal } from '../../controllers/edit-post-create-context';
15
20
  import { ExitWarningModalProvider, useExitWarningModal } from '../../controllers/exit-warning-modal-context';
16
21
  import { FormContextProvider } from '../../controllers/form-context';
17
- import { LinkCreatePluginsProvider } from '../../controllers/plugin-context';
18
- import { ConfirmDismissDialog } from './confirm-dismiss-dialog';
19
- import { EditModal } from './edit-modal';
20
- import { ErrorBoundary } from './error-boundary';
22
+ import { LinkCreatePluginsProvider, useLinkCreatePlugins } from '../../controllers/plugin-context';
21
23
  import { messages } from './messages';
22
- import { ModalHero } from './modal-hero';
23
24
  export var TEST_ID = 'link-create';
24
25
  var SCREEN_ID = 'linkCreateScreen';
25
- var LinkCreateContent = function LinkCreateContent(_ref) {
26
- var plugins = _ref.plugins,
27
- entityKey = _ref.entityKey;
28
- var chosenOne = plugins.find(function (plugin) {
29
- return plugin.key === entityKey;
30
- });
31
- if (!chosenOne) {
32
- throw new Error('Make sure you specified a valid entityKey');
33
- }
34
- return jsx(Fragment, null, chosenOne.form);
35
- };
36
- var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
37
- var active = _ref2.active,
38
- modalTitle = _ref2.modalTitle,
39
- onCreate = _ref2.onCreate,
40
- onFailure = _ref2.onFailure,
41
- onCancel = _ref2.onCancel,
42
- onComplete = _ref2.onComplete,
43
- onOpenComplete = _ref2.onOpenComplete,
44
- onCloseComplete = _ref2.onCloseComplete,
45
- _ref2$testId = _ref2.testId,
46
- testId = _ref2$testId === void 0 ? TEST_ID : _ref2$testId,
47
- plugins = _ref2.plugins,
48
- entityKey = _ref2.entityKey,
49
- modalHero = _ref2.modalHero;
26
+ var LinkCreateWithModal = function LinkCreateWithModal(_ref) {
27
+ var active = _ref.active,
28
+ modalTitle = _ref.modalTitle,
29
+ onCreate = _ref.onCreate,
30
+ onFailure = _ref.onFailure,
31
+ onCancel = _ref.onCancel,
32
+ onComplete = _ref.onComplete,
33
+ onOpenComplete = _ref.onOpenComplete,
34
+ onCloseComplete = _ref.onCloseComplete,
35
+ _ref$testId = _ref.testId,
36
+ testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
37
+ plugins = _ref.plugins,
38
+ entityKey = _ref.entityKey,
39
+ modalHero = _ref.modalHero;
50
40
  var intl = useIntl();
51
41
  var _useExitWarningModal = useExitWarningModal(),
52
42
  getShouldShowWarning = _useExitWarningModal.getShouldShowWarning;
@@ -54,6 +44,10 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
54
44
  _useState2 = _slicedToArray(_useState, 2),
55
45
  showExitWarning = _useState2[0],
56
46
  setShowExitWarning = _useState2[1];
47
+ var _useEditPostCreateMod = useEditPostCreateModal(),
48
+ editViewPayload = _useEditPostCreateMod.editViewPayload;
49
+ var _useLinkCreatePlugins = useLinkCreatePlugins(),
50
+ activePlugin = _useLinkCreatePlugins.activePlugin;
57
51
  var handleCancel = useCallback(function () {
58
52
  if (getShouldShowWarning() && !showExitWarning) {
59
53
  setShowExitWarning(true);
@@ -85,10 +79,13 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
85
79
  entityKey: entityKey
86
80
  })))))), onComplete && jsx(EditModal, {
87
81
  onCloseComplete: onCloseComplete,
88
- onClose: onComplete
82
+ onClose: onComplete,
83
+ editViewPayload: editViewPayload,
84
+ activePlugin: activePlugin
89
85
  }), jsx(ConfirmDismissDialog, {
90
86
  active: showExitWarning,
91
- onClose: handleCloseExitWarning
87
+ onClose: handleCloseExitWarning,
88
+ onCancel: onCancel
92
89
  }));
93
90
  };
94
91
  var LinkCreateModal = function LinkCreateModal(props) {
@@ -107,18 +104,18 @@ var LinkCreateModal = function LinkCreateModal(props) {
107
104
  }, function (pluginsProvider) {
108
105
  return jsx(EditPostCreateModalProvider, {
109
106
  active: !!props.active
110
- }, function (_ref3) {
107
+ }, function (_ref2) {
111
108
  var _pluginsProvider$acti;
112
- var setEditViewPayload = _ref3.setEditViewPayload,
113
- editViewPayload = _ref3.editViewPayload,
114
- shouldActivateEditView = _ref3.shouldActivateEditView,
115
- enableEditView = _ref3.enableEditView;
109
+ var setEditViewPayload = _ref2.setEditViewPayload,
110
+ editViewPayload = _ref2.editViewPayload,
111
+ shouldActivateEditView = _ref2.shouldActivateEditView,
112
+ enableEditView = _ref2.enableEditView;
116
113
  return jsx(FormContextProvider, {
117
114
  enableEditView: pluginsProvider !== null && pluginsProvider !== void 0 && (_pluginsProvider$acti = pluginsProvider.activePlugin) !== null && _pluginsProvider$acti !== void 0 && _pluginsProvider$acti.editView && props !== null && props !== void 0 && props.onComplete ? enableEditView : undefined
118
115
  }, jsx(ExitWarningModalProvider, null, jsx(LinkCreateWithModal, _extends({}, props, {
119
116
  active: props.active && !editViewPayload,
120
117
  onCreate: ( /*#__PURE__*/function () {
121
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload) {
118
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload) {
122
119
  var _props$onCreate;
123
120
  return _regeneratorRuntime.wrap(function _callee$(_context) {
124
121
  while (1) switch (_context.prev = _context.next) {
@@ -143,7 +140,7 @@ var LinkCreateModal = function LinkCreateModal(props) {
143
140
  }, _callee);
144
141
  }));
145
142
  return function (_x) {
146
- return _ref4.apply(this, arguments);
143
+ return _ref3.apply(this, arguments);
147
144
  };
148
145
  }()),
149
146
  onCloseComplete: function onCloseComplete() {
@@ -1,5 +1,7 @@
1
+ import type { PackageMetaDataType } from './utils/analytics/analytics.codegen';
1
2
  export declare const ANALYTICS_CHANNEL = "media";
2
3
  export declare const COMPONENT_NAME = "linkCreate";
3
4
  export declare const CREATE_FORM_MAX_WIDTH_IN_PX = "480";
4
5
  export declare const CREATE_FORM_MIN_HEIGHT_IN_PX = "200";
5
6
  export declare const LINK_CREATE_FORM_POST_CREATE_FIELD = "__post_create__";
7
+ export declare const PACKAGE_DATA: PackageMetaDataType;
@@ -2,4 +2,4 @@ import React from 'react';
2
2
  import { type AnalyticsEventAttributes } from '../../../common/utils/analytics/analytics.codegen';
3
3
  export declare const Button: React.ForwardRefExoticComponent<Pick<import("@atlaskit/button").ButtonProps & React.RefAttributes<HTMLElement> & {
4
4
  actionSubjectId: "create" | "edit" | "cancel" | "confirm";
5
- }, "key" | keyof import("@atlaskit/button").ButtonProps | "actionSubjectId"> & React.RefAttributes<HTMLElement>>;
5
+ }, "actionSubjectId" | "key" | keyof import("@atlaskit/button").ButtonProps> & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export type ConfirmDismissDialogProps = {
3
+ active: boolean;
4
+ onClose: () => void;
5
+ onCancel?: () => void;
6
+ };
7
+ export declare const ConfirmDismissDialog: ({ active, onClose, onCancel }: ConfirmDismissDialogProps) => JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { type CreatePayload, type LinkCreatePlugin } from '../../types';
3
+ import { Modal } from '../ModalDialog';
4
+ type EditModalProps = {
5
+ onClose: () => void;
6
+ onCloseComplete?: React.ComponentProps<typeof Modal>['onCloseComplete'];
7
+ editViewPayload?: CreatePayload;
8
+ activePlugin?: LinkCreatePlugin<string> | null;
9
+ };
10
+ export declare const EditModal: ({ onClose, onCloseComplete, editViewPayload, activePlugin, }: EditModalProps) => JSX.Element;
11
+ export {};
@@ -2,5 +2,5 @@ import { type PropsWithChildren } from 'react';
2
2
  type ErrorBoundaryProps = PropsWithChildren<{
3
3
  errorComponent?: JSX.Element;
4
4
  }>;
5
- export declare const ErrorBoundary: ({ children, errorComponent, }: ErrorBoundaryProps) => JSX.Element;
5
+ export declare const ErrorBoundary: ({ children, errorComponent }: ErrorBoundaryProps) => JSX.Element;
6
6
  export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { LinkCreatePlugin } from '../../types';
3
+ type LinkCreateContentProps = {
4
+ plugins: LinkCreatePlugin[];
5
+ entityKey: string;
6
+ };
7
+ export declare const LinkCreateContent: ({ plugins, entityKey }: LinkCreateContentProps) => JSX.Element;
8
+ export {};
@@ -1 +1 @@
1
- export { useLinkCreateAnalytics, withLinkCreateAnalyticsContext, } from './context';
1
+ export { useLinkCreateAnalytics, withLinkCreateAnalyticsContext } from './context';
@@ -3,7 +3,7 @@ type ExitWarningModalContextValue = {
3
3
  getShouldShowWarning: () => boolean;
4
4
  setShouldShowWarning: (show: boolean) => void;
5
5
  };
6
- export declare const ExitWarningModalProvider: ({ children, }: {
6
+ export declare const ExitWarningModalProvider: ({ children }: {
7
7
  children: React.ReactNode;
8
8
  }) => JSX.Element;
9
9
  export declare const useExitWarningModal: () => ExitWarningModalContextValue;
@@ -1 +1 @@
1
- export { FormContextProvider, useFormContext, withLinkCreateFormContext, } from './main';
1
+ export { FormContextProvider, useFormContext, withLinkCreateFormContext } from './main';
@@ -1,6 +1,6 @@
1
1
  export type { CreateFormProps } from './ui/index';
2
2
  export type { LinkCreateProps, LinkCreatePlugin, LinkCreateWithModalProps, CreatePayload, EditViewProps, } from './common/types';
3
- export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy, } from './ui/index';
4
- export { useLinkCreateCallback, LinkCreateCallbackProvider, } from './controllers/callback-context';
3
+ export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy, UserPicker, } from './ui/index';
4
+ export { useLinkCreateCallback, LinkCreateCallbackProvider } from './controllers/callback-context';
5
5
  export type { Validator, ValidatorMap } from './common/types';
6
6
  export { FORM_ERROR } from 'final-form';
@@ -9,4 +9,4 @@ export type FormSpyProps<T> = {
9
9
  * FormSpy component so that we can control selectively
10
10
  * how much of the API we are commited to.
11
11
  */
12
- export declare const FormSpy: <T extends Record<string, unknown>>({ children, }: FormSpyProps<T>) => JSX.Element;
12
+ export declare const FormSpy: <T extends Record<string, unknown>>({ children }: FormSpyProps<T>) => JSX.Element;
@@ -0,0 +1 @@
1
+ export { UserPicker } from './main';
@@ -0,0 +1,8 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { type UserPickerProps } from './types';
4
+ export declare const TEST_ID = "link-create-user-picker";
5
+ /**
6
+ * A user picker utilising the SmartUserPicker.
7
+ */
8
+ export declare function UserPicker({ productKey, siteId, name, label, placeholder, validators, testId, defaultValue, }: UserPickerProps): jsx.JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { type Validator } from '../../../common/types';
2
+ export type UserPickerProps = {
3
+ /** Name to pass into the <Field> */
4
+ name: string;
5
+ /** Refers to a product identifier, Jira, Confluence, Townsquare, ect. */
6
+ productKey: string;
7
+ /** Identifier for the product's tenant, also known as tenantId or cloudId */
8
+ siteId: string;
9
+ /** The label text above the component */
10
+ label?: string;
11
+ /** Placeholder text to display in the text field whenever it is empty. */
12
+ placeholder?: string;
13
+ /** Validators for this field */
14
+ validators?: Validator[];
15
+ testId?: string;
16
+ defaultValue: User;
17
+ };
18
+ type User = {
19
+ id: string;
20
+ userId: string;
21
+ name: string;
22
+ avatar: string;
23
+ email: string;
24
+ };
25
+ export {};
@@ -1,4 +1,5 @@
1
- export { default } from './main';
1
+ export { default } from './modal-create';
2
+ export { default as InlineCreate } from './inline-create';
2
3
  export { TextField } from './create-form/textfield';
3
4
  export { CreateForm } from './create-form/main';
4
5
  export { CreateFormLoader } from './create-form/form-loader';
@@ -6,3 +7,4 @@ export type { CreateFormProps } from './create-form/main';
6
7
  export { Select } from './create-form/select';
7
8
  export { AsyncSelect } from './create-form/async-select';
8
9
  export { FormSpy } from './create-form/form-spy';
10
+ export { UserPicker } from './create-form/user-picker';
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ import type { LinkCreateWithModalProps } from '../../common/types';
4
+ declare const ComposedLinkCreate: import("react").MemoExoticComponent<(props: LinkCreateWithModalProps) => jsx.JSX.Element>;
5
+ export default ComposedLinkCreate;
@@ -0,0 +1,5 @@
1
+ import { jsx } from '@emotion/react';
2
+ import type { LinkCreateProps } from '../../common/types';
3
+ export declare const TEST_ID = "link-create";
4
+ declare const InlineCreate: (props: LinkCreateProps) => jsx.JSX.Element;
5
+ export default InlineCreate;