@atlaskit/link-create 1.5.1 → 1.6.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 (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/controllers/edit-post-create-context/index.js +14 -3
  3. package/dist/cjs/controllers/plugin-context/index.js +1 -1
  4. package/dist/cjs/ui/create-form/main.js +24 -6
  5. package/dist/cjs/ui/link-create/edit-modal/index.js +12 -3
  6. package/dist/cjs/ui/link-create/main.js +53 -6
  7. package/dist/cjs/ui/main.js +1 -1
  8. package/dist/es2019/controllers/edit-post-create-context/index.js +11 -4
  9. package/dist/es2019/controllers/plugin-context/index.js +1 -1
  10. package/dist/es2019/ui/create-form/main.js +20 -3
  11. package/dist/es2019/ui/link-create/edit-modal/index.js +13 -3
  12. package/dist/es2019/ui/link-create/main.js +38 -6
  13. package/dist/es2019/ui/main.js +1 -1
  14. package/dist/esm/controllers/edit-post-create-context/index.js +15 -4
  15. package/dist/esm/controllers/plugin-context/index.js +1 -1
  16. package/dist/esm/ui/create-form/main.js +24 -5
  17. package/dist/esm/ui/link-create/edit-modal/index.js +12 -3
  18. package/dist/esm/ui/link-create/main.js +54 -7
  19. package/dist/esm/ui/main.js +1 -1
  20. package/dist/types/common/types.d.ts +14 -0
  21. package/dist/types/controllers/edit-post-create-context/index.d.ts +23 -3
  22. package/dist/types/controllers/plugin-context/index.d.ts +4 -1
  23. package/dist/types/ui/create-form/main.d.ts +18 -2
  24. package/dist/types/ui/link-create/edit-modal/index.d.ts +8 -4
  25. package/dist/types/ui/link-create/main.d.ts +3 -3
  26. package/dist/types-ts4.5/common/types.d.ts +14 -0
  27. package/dist/types-ts4.5/controllers/edit-post-create-context/index.d.ts +23 -3
  28. package/dist/types-ts4.5/controllers/plugin-context/index.d.ts +4 -1
  29. package/dist/types-ts4.5/ui/create-form/main.d.ts +20 -2
  30. package/dist/types-ts4.5/ui/link-create/edit-modal/index.d.ts +8 -4
  31. package/dist/types-ts4.5/ui/link-create/main.d.ts +3 -3
  32. package/package.json +1 -1
  33. package/report.api.md +25 -4
  34. package/tmp/api-report-tmp.d.ts +25 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/link-create
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#42487](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42487) [`0b6245f9d18`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0b6245f9d18) - EDM-8376: Introduces a editView field to the LinkCreatePlugin interface which will allow plugins to register a screen to edit objects post-creation in a future release.
8
+
3
9
  ## 1.5.1
4
10
 
5
11
  ### Patch Changes
@@ -12,11 +12,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
  var EditPostCreateModalContext = /*#__PURE__*/(0, _react.createContext)({
14
14
  editViewPayload: undefined,
15
- setEditViewPayload: function setEditViewPayload() {}
15
+ setEditViewPayload: function setEditViewPayload() {},
16
+ enableEditView: function enableEditView() {},
17
+ shouldActivateEditView: function shouldActivateEditView() {
18
+ return false;
19
+ }
16
20
  });
17
21
  var EditPostCreateModalProvider = exports.EditPostCreateModalProvider = function EditPostCreateModalProvider(_ref) {
18
22
  var active = _ref.active,
19
23
  children = _ref.children;
24
+ var _shouldActivateEditView = (0, _react.useRef)(false);
20
25
  var _useState = (0, _react.useState)(undefined),
21
26
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
22
27
  editViewPayload = _useState2[0],
@@ -24,7 +29,13 @@ var EditPostCreateModalProvider = exports.EditPostCreateModalProvider = function
24
29
  var value = (0, _react.useMemo)(function () {
25
30
  return {
26
31
  editViewPayload: editViewPayload,
27
- setEditViewPayload: setEditViewPayload
32
+ setEditViewPayload: setEditViewPayload,
33
+ enableEditView: function enableEditView(enable) {
34
+ _shouldActivateEditView.current = enable;
35
+ },
36
+ shouldActivateEditView: function shouldActivateEditView() {
37
+ return _shouldActivateEditView.current;
38
+ }
28
39
  };
29
40
  }, [editViewPayload, setEditViewPayload]);
30
41
  if (editViewPayload && !active) {
@@ -32,7 +43,7 @@ var EditPostCreateModalProvider = exports.EditPostCreateModalProvider = function
32
43
  }
33
44
  return /*#__PURE__*/_react.default.createElement(EditPostCreateModalContext.Provider, {
34
45
  value: value
35
- }, children);
46
+ }, typeof children === 'function' ? children(value) : children);
36
47
  };
37
48
  var useEditPostCreateModal = exports.useEditPostCreateModal = function useEditPostCreateModal() {
38
49
  var value = (0, _react.useContext)(EditPostCreateModalContext);
@@ -28,7 +28,7 @@ var LinkCreatePluginsProvider = exports.LinkCreatePluginsProvider = function Lin
28
28
  }, [entityKey, plugins]);
29
29
  return /*#__PURE__*/_react.default.createElement(LinkCreatePluginsContext.Provider, {
30
30
  value: value
31
- }, children);
31
+ }, typeof children === 'function' ? children(value) : children);
32
32
  };
33
33
  var useLinkCreatePlugins = exports.useLinkCreatePlugins = function useLinkCreatePlugins() {
34
34
  var value = (0, _react.useContext)(LinkCreatePluginsContext);
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.TEST_ID = exports.CreateForm = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
12
  var _react = require("react");
12
13
  var _react2 = require("@emotion/react");
13
14
  var _reactFinalForm = require("react-final-form");
14
15
  var _analyticsNext = require("@atlaskit/analytics-next");
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
17
  var _primitives = require("@atlaskit/primitives");
16
18
  var _constants = require("../../common/constants");
17
19
  var _analytics = _interopRequireDefault(require("../../common/utils/analytics/analytics.codegen"));
@@ -20,12 +22,14 @@ var _formFooter = require("./form-footer");
20
22
  var _formLoader = require("./form-loader");
21
23
  var _utils = require("./utils");
22
24
  var _excluded = ["submitting"];
23
- /** @jsx jsx */
25
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
26
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** @jsx jsx */
24
27
  var formStyles = (0, _react2.css)({
25
28
  maxWidth: "".concat(_constants.CREATE_FORM_MAX_WIDTH_IN_PX, "px"),
26
29
  padding: "0 0 ".concat("var(--ds-space-300, 24px)", " 0"),
27
30
  margin: "var(--ds-space-0, 0px)".concat(" auto")
28
31
  });
32
+ var RESERVED_FIELDS = [_constants.LINK_CREATE_FORM_POST_CREATE_FIELD];
29
33
  var TEST_ID = exports.TEST_ID = 'link-create-form';
30
34
  var CreateForm = exports.CreateForm = function CreateForm(_ref) {
31
35
  var children = _ref.children,
@@ -41,10 +45,11 @@ var CreateForm = exports.CreateForm = function CreateForm(_ref) {
41
45
  var _useFormContext = (0, _formContext.useFormContext)(),
42
46
  getValidators = _useFormContext.getValidators,
43
47
  formErrorMessage = _useFormContext.formErrorMessage,
44
- setFormDirty = _useFormContext.setFormDirty;
48
+ setFormDirty = _useFormContext.setFormDirty,
49
+ enableEditView = _useFormContext.enableEditView;
45
50
  var handleSubmit = (0, _react.useCallback)( /*#__PURE__*/function () {
46
51
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(data) {
47
- var validators, errors;
52
+ var validators, errors, shouldEnableEditView, formData;
48
53
  return _regenerator.default.wrap(function _callee$(_context) {
49
54
  while (1) switch (_context.prev = _context.next) {
50
55
  case 0:
@@ -60,8 +65,21 @@ var CreateForm = exports.CreateForm = function CreateForm(_ref) {
60
65
  }
61
66
  return _context.abrupt("return", errors);
62
67
  case 5:
68
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.link-create.enable-edit')) {
69
+ _context.next = 9;
70
+ break;
71
+ }
72
+ shouldEnableEditView = data[_constants.LINK_CREATE_FORM_POST_CREATE_FIELD], formData = (0, _objectWithoutProperties2.default)(data, [_constants.LINK_CREATE_FORM_POST_CREATE_FIELD].map(_toPropertyKey));
73
+ /**
74
+ * If form has post-create field set to trigger post-create edit
75
+ * send this to the form context so we know what to do next
76
+ * if submission is successful
77
+ */
78
+ enableEditView === null || enableEditView === void 0 || enableEditView(!!shouldEnableEditView);
79
+ return _context.abrupt("return", onSubmit(formData));
80
+ case 9:
63
81
  return _context.abrupt("return", onSubmit(data));
64
- case 6:
82
+ case 10:
65
83
  case "end":
66
84
  return _context.stop();
67
85
  }
@@ -70,7 +88,7 @@ var CreateForm = exports.CreateForm = function CreateForm(_ref) {
70
88
  return function (_x) {
71
89
  return _ref2.apply(this, arguments);
72
90
  };
73
- }(), [createAnalyticsEvent, getValidators, onSubmit]);
91
+ }(), [createAnalyticsEvent, getValidators, onSubmit, enableEditView]);
74
92
  var handleCancel = (0, _react.useCallback)(function () {
75
93
  createAnalyticsEvent((0, _analytics.default)('ui.button.clicked.cancel', {})).fire(_constants.ANALYTICS_CHANNEL);
76
94
  onCancel && onCancel();
@@ -9,17 +9,26 @@ exports.EditModal = void 0;
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
11
11
  var _editPostCreateContext = require("../../../controllers/edit-post-create-context");
12
+ var _pluginContext = require("../../../controllers/plugin-context");
12
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
15
  var EditModal = exports.EditModal = function EditModal(_ref) {
15
- var onClose = _ref.onClose;
16
+ var _activePlugin$editVie;
17
+ var onClose = _ref.onClose,
18
+ onCloseComplete = _ref.onCloseComplete;
16
19
  var _useEditPostCreateMod = (0, _editPostCreateContext.useEditPostCreateModal)(),
17
20
  editViewPayload = _useEditPostCreateMod.editViewPayload;
21
+ var _useLinkCreatePlugins = (0, _pluginContext.useLinkCreatePlugins)(),
22
+ activePlugin = _useLinkCreatePlugins.activePlugin;
18
23
  return /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTransition, null, !!editViewPayload && /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
19
24
  testId: "link-create-edit-modal",
20
25
  onClose: onClose,
21
26
  shouldScrollInViewport: true,
22
27
  width: "calc(100vw - 120px)",
23
- height: "calc(100vh - 120px)"
24
- }));
28
+ height: "calc(100vh - 120px)",
29
+ onCloseComplete: onCloseComplete
30
+ }, activePlugin === null || activePlugin === void 0 || (_activePlugin$editVie = activePlugin.editView) === null || _activePlugin$editVie === void 0 ? void 0 : _activePlugin$editVie.call(activePlugin, {
31
+ payload: editViewPayload,
32
+ onClose: onClose
33
+ })));
25
34
  };
@@ -129,6 +129,7 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref4) {
129
129
  }, (0, _react2.jsx)(_modalDialog.ModalHeader, null, (0, _react2.jsx)(_modalDialog.ModalTitle, null, modalTitle || intl.formatMessage(_messages.messages.heading))), (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)(LinkCreate, (0, _extends2.default)({}, createProps, {
130
130
  onCancel: handleCancel
131
131
  }))))), (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.link-create.enable-edit') && (0, _react2.jsx)(_editModal.EditModal, {
132
+ onCloseComplete: onCloseComplete,
132
133
  onClose: handleCancel
133
134
  }), (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.link-create.confirm-dismiss-dialog') && (0, _react2.jsx)(_confirmDismissDialog.ConfirmDismissDialog, {
134
135
  active: dismissDialog,
@@ -136,14 +137,60 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref4) {
136
137
  onConfirmDismiss: handleConfirmDismiss
137
138
  }));
138
139
  };
139
- var _default = exports.default = (0, _formContext.withLinkCreateFormContext)(function (props) {
140
+ var LinkCreateModalInternal = function LinkCreateModalInternal(props) {
140
141
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.link-create.enable-edit')) {
141
142
  return (0, _react2.jsx)(_pluginContext.LinkCreatePluginsProvider, {
142
143
  plugins: props.plugins,
143
144
  entityKey: props.entityKey
144
- }, (0, _react2.jsx)(_editPostCreateContext.EditPostCreateModalProvider, {
145
- active: !!props.active
146
- }, (0, _react2.jsx)(LinkCreateWithModal, props)));
145
+ }, function (pluginsProvider) {
146
+ return (0, _react2.jsx)(_editPostCreateContext.EditPostCreateModalProvider, {
147
+ active: !!props.active
148
+ }, function (_ref5) {
149
+ var _pluginsProvider$acti;
150
+ var setEditViewPayload = _ref5.setEditViewPayload,
151
+ editViewPayload = _ref5.editViewPayload,
152
+ shouldActivateEditView = _ref5.shouldActivateEditView,
153
+ enableEditView = _ref5.enableEditView;
154
+ return (0, _react2.jsx)(_formContext.FormContextProvider, {
155
+ enableEditView: pluginsProvider !== null && pluginsProvider !== void 0 && (_pluginsProvider$acti = pluginsProvider.activePlugin) !== null && _pluginsProvider$acti !== void 0 && _pluginsProvider$acti.editView ? enableEditView : undefined
156
+ }, (0, _react2.jsx)(LinkCreateWithModal, (0, _extends2.default)({}, props, {
157
+ active: props.active && !editViewPayload,
158
+ onCreate: /*#__PURE__*/function () {
159
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(payload) {
160
+ var _props$onCreate;
161
+ return _regenerator.default.wrap(function _callee2$(_context2) {
162
+ while (1) switch (_context2.prev = _context2.next) {
163
+ case 0:
164
+ _context2.next = 2;
165
+ return (_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload);
166
+ case 2:
167
+ // if onComplete exists then there is an edit flow
168
+ if (props.onComplete) {
169
+ if (shouldActivateEditView()) {
170
+ //edit button is pressed
171
+ setEditViewPayload(payload);
172
+ } else {
173
+ //create button is pressed
174
+ props.onComplete();
175
+ }
176
+ }
177
+ case 3:
178
+ case "end":
179
+ return _context2.stop();
180
+ }
181
+ }, _callee2);
182
+ }));
183
+ return function (_x2) {
184
+ return _ref6.apply(this, arguments);
185
+ };
186
+ }()
187
+ })));
188
+ });
189
+ });
147
190
  }
148
- return (0, _react2.jsx)(LinkCreateWithModal, props);
149
- });
191
+ return (0, _react2.jsx)(_formContext.FormContextProvider, null, (0, _react2.jsx)(LinkCreateWithModal, props));
192
+ };
193
+ var LinkCreateModalPublic = function LinkCreateModalPublic(props) {
194
+ return (0, _react2.jsx)(LinkCreateModalInternal, props);
195
+ };
196
+ var _default = exports.default = LinkCreateModalPublic;
@@ -35,7 +35,7 @@ var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsConte
35
35
  }));
36
36
  var PACKAGE_DATA = exports.PACKAGE_DATA = {
37
37
  packageName: "@atlaskit/link-create" || '',
38
- packageVersion: "1.5.1" || '',
38
+ packageVersion: "1.6.0" || '',
39
39
  componentName: _constants.COMPONENT_NAME,
40
40
  source: _constants.COMPONENT_NAME
41
41
  };
@@ -1,23 +1,30 @@
1
- import React, { createContext, useContext, useMemo, useState } from 'react';
1
+ import React, { createContext, useContext, useMemo, useRef, useState } from 'react';
2
2
  const EditPostCreateModalContext = /*#__PURE__*/createContext({
3
3
  editViewPayload: undefined,
4
- setEditViewPayload: () => {}
4
+ setEditViewPayload: () => {},
5
+ enableEditView: () => {},
6
+ shouldActivateEditView: () => false
5
7
  });
6
8
  export const EditPostCreateModalProvider = ({
7
9
  active,
8
10
  children
9
11
  }) => {
12
+ const shouldActivateEditView = useRef(false);
10
13
  const [editViewPayload, setEditViewPayload] = useState(undefined);
11
14
  const value = useMemo(() => ({
12
15
  editViewPayload,
13
- setEditViewPayload
16
+ setEditViewPayload,
17
+ enableEditView: enable => {
18
+ shouldActivateEditView.current = enable;
19
+ },
20
+ shouldActivateEditView: () => shouldActivateEditView.current
14
21
  }), [editViewPayload, setEditViewPayload]);
15
22
  if (editViewPayload && !active) {
16
23
  setEditViewPayload(undefined);
17
24
  }
18
25
  return /*#__PURE__*/React.createElement(EditPostCreateModalContext.Provider, {
19
26
  value: value
20
- }, children);
27
+ }, typeof children === 'function' ? children(value) : children);
21
28
  };
22
29
  export const useEditPostCreateModal = () => {
23
30
  const value = useContext(EditPostCreateModalContext);
@@ -14,7 +14,7 @@ export const LinkCreatePluginsProvider = ({
14
14
  }, [entityKey, plugins]);
15
15
  return /*#__PURE__*/React.createElement(LinkCreatePluginsContext.Provider, {
16
16
  value: value
17
- }, children);
17
+ }, typeof children === 'function' ? children(value) : children);
18
18
  };
19
19
  export const useLinkCreatePlugins = () => {
20
20
  const value = useContext(LinkCreatePluginsContext);
@@ -3,8 +3,9 @@ import { useCallback } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import { Form, FormSpy } from 'react-final-form';
5
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
7
  import { Box } from '@atlaskit/primitives';
7
- import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
8
+ import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
8
9
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
9
10
  import { useFormContext } from '../../controllers/form-context';
10
11
  import { CreateFormFooter } from './form-footer';
@@ -15,6 +16,7 @@ const formStyles = css({
15
16
  padding: `0 0 ${"var(--ds-space-300, 24px)"} 0`,
16
17
  margin: `${"var(--ds-space-0, 0px)"} auto`
17
18
  });
19
+ const RESERVED_FIELDS = [LINK_CREATE_FORM_POST_CREATE_FIELD];
18
20
  export const TEST_ID = 'link-create-form';
19
21
  export const CreateForm = ({
20
22
  children,
@@ -31,7 +33,8 @@ export const CreateForm = ({
31
33
  const {
32
34
  getValidators,
33
35
  formErrorMessage,
34
- setFormDirty
36
+ setFormDirty,
37
+ enableEditView
35
38
  } = useFormContext();
36
39
  const handleSubmit = useCallback(async data => {
37
40
  createAnalyticsEvent(createEventPayload('ui.button.clicked.create', {})).fire(ANALYTICS_CHANNEL);
@@ -43,8 +46,22 @@ export const CreateForm = ({
43
46
  if (Object.keys(errors).length !== 0) {
44
47
  return errors;
45
48
  }
49
+ if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
50
+ const {
51
+ [LINK_CREATE_FORM_POST_CREATE_FIELD]: shouldEnableEditView,
52
+ ...formData
53
+ } = data;
54
+
55
+ /**
56
+ * If form has post-create field set to trigger post-create edit
57
+ * send this to the form context so we know what to do next
58
+ * if submission is successful
59
+ */
60
+ enableEditView === null || enableEditView === void 0 ? void 0 : enableEditView(!!shouldEnableEditView);
61
+ return onSubmit(formData);
62
+ }
46
63
  return onSubmit(data);
47
- }, [createAnalyticsEvent, getValidators, onSubmit]);
64
+ }, [createAnalyticsEvent, getValidators, onSubmit, enableEditView]);
48
65
  const handleCancel = useCallback(() => {
49
66
  createAnalyticsEvent(createEventPayload('ui.button.clicked.cancel', {})).fire(ANALYTICS_CHANNEL);
50
67
  onCancel && onCancel();
@@ -1,17 +1,27 @@
1
1
  import React from 'react';
2
2
  import Modal, { ModalTransition } from '@atlaskit/modal-dialog';
3
3
  import { useEditPostCreateModal } from '../../../controllers/edit-post-create-context';
4
+ import { useLinkCreatePlugins } from '../../../controllers/plugin-context';
4
5
  export const EditModal = ({
5
- onClose
6
+ onClose,
7
+ onCloseComplete
6
8
  }) => {
9
+ var _activePlugin$editVie;
7
10
  const {
8
11
  editViewPayload
9
12
  } = useEditPostCreateModal();
13
+ const {
14
+ activePlugin
15
+ } = useLinkCreatePlugins();
10
16
  return /*#__PURE__*/React.createElement(ModalTransition, null, !!editViewPayload && /*#__PURE__*/React.createElement(Modal, {
11
17
  testId: "link-create-edit-modal",
12
18
  onClose: onClose,
13
19
  shouldScrollInViewport: true,
14
20
  width: "calc(100vw - 120px)",
15
- height: "calc(100vh - 120px)"
16
- }));
21
+ height: "calc(100vh - 120px)",
22
+ onCloseComplete: onCloseComplete
23
+ }, activePlugin === null || activePlugin === void 0 ? void 0 : (_activePlugin$editVie = activePlugin.editView) === null || _activePlugin$editVie === void 0 ? void 0 : _activePlugin$editVie.call(activePlugin, {
24
+ payload: editViewPayload,
25
+ onClose
26
+ })));
17
27
  };
@@ -9,7 +9,7 @@ import { Box } from '@atlaskit/primitives';
9
9
  import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
10
10
  import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
11
11
  import { EditPostCreateModalProvider } from '../../controllers/edit-post-create-context';
12
- import { useFormContext, withLinkCreateFormContext } from '../../controllers/form-context';
12
+ import { FormContextProvider, useFormContext } from '../../controllers/form-context';
13
13
  import { LinkCreatePluginsProvider } from '../../controllers/plugin-context';
14
14
  import { ConfirmDismissDialog } from './confirm-dismiss-dialog';
15
15
  import { EditModal } from './edit-modal';
@@ -96,6 +96,7 @@ const LinkCreateWithModal = ({
96
96
  }, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(LinkCreate, _extends({}, createProps, {
97
97
  onCancel: handleCancel
98
98
  }))))), getBooleanFF('platform.linking-platform.link-create.enable-edit') && jsx(EditModal, {
99
+ onCloseComplete: onCloseComplete,
99
100
  onClose: handleCancel
100
101
  }), getBooleanFF('platform.linking-platform.link-create.confirm-dismiss-dialog') && jsx(ConfirmDismissDialog, {
101
102
  active: dismissDialog,
@@ -103,14 +104,45 @@ const LinkCreateWithModal = ({
103
104
  onConfirmDismiss: handleConfirmDismiss
104
105
  }));
105
106
  };
106
- export default withLinkCreateFormContext(props => {
107
+ const LinkCreateModalInternal = props => {
107
108
  if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
108
109
  return jsx(LinkCreatePluginsProvider, {
109
110
  plugins: props.plugins,
110
111
  entityKey: props.entityKey
111
- }, jsx(EditPostCreateModalProvider, {
112
+ }, pluginsProvider => jsx(EditPostCreateModalProvider, {
112
113
  active: !!props.active
113
- }, jsx(LinkCreateWithModal, props)));
114
+ }, ({
115
+ setEditViewPayload,
116
+ editViewPayload,
117
+ shouldActivateEditView,
118
+ enableEditView
119
+ }) => {
120
+ var _pluginsProvider$acti;
121
+ return jsx(FormContextProvider, {
122
+ enableEditView: pluginsProvider !== null && pluginsProvider !== void 0 && (_pluginsProvider$acti = pluginsProvider.activePlugin) !== null && _pluginsProvider$acti !== void 0 && _pluginsProvider$acti.editView ? enableEditView : undefined
123
+ }, jsx(LinkCreateWithModal, _extends({}, props, {
124
+ active: props.active && !editViewPayload,
125
+ onCreate: async payload => {
126
+ var _props$onCreate;
127
+ await ((_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload));
128
+
129
+ // if onComplete exists then there is an edit flow
130
+ if (props.onComplete) {
131
+ if (shouldActivateEditView()) {
132
+ //edit button is pressed
133
+ setEditViewPayload(payload);
134
+ } else {
135
+ //create button is pressed
136
+ props.onComplete();
137
+ }
138
+ }
139
+ }
140
+ })));
141
+ }));
114
142
  }
115
- return jsx(LinkCreateWithModal, props);
116
- });
143
+ return jsx(FormContextProvider, null, jsx(LinkCreateWithModal, props));
144
+ };
145
+ const LinkCreateModalPublic = props => {
146
+ return jsx(LinkCreateModalInternal, props);
147
+ };
148
+ export default LinkCreateModalPublic;
@@ -26,7 +26,7 @@ const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE
26
26
  }));
27
27
  export const PACKAGE_DATA = {
28
28
  packageName: "@atlaskit/link-create" || '',
29
- packageVersion: "1.5.1" || '',
29
+ packageVersion: "1.6.0" || '',
30
30
  componentName: COMPONENT_NAME,
31
31
  source: COMPONENT_NAME
32
32
  };
@@ -1,12 +1,17 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { createContext, useContext, useMemo, useState } from 'react';
2
+ import React, { createContext, useContext, useMemo, useRef, useState } from 'react';
3
3
  var EditPostCreateModalContext = /*#__PURE__*/createContext({
4
4
  editViewPayload: undefined,
5
- setEditViewPayload: function setEditViewPayload() {}
5
+ setEditViewPayload: function setEditViewPayload() {},
6
+ enableEditView: function enableEditView() {},
7
+ shouldActivateEditView: function shouldActivateEditView() {
8
+ return false;
9
+ }
6
10
  });
7
11
  export var EditPostCreateModalProvider = function EditPostCreateModalProvider(_ref) {
8
12
  var active = _ref.active,
9
13
  children = _ref.children;
14
+ var _shouldActivateEditView = useRef(false);
10
15
  var _useState = useState(undefined),
11
16
  _useState2 = _slicedToArray(_useState, 2),
12
17
  editViewPayload = _useState2[0],
@@ -14,7 +19,13 @@ export var EditPostCreateModalProvider = function EditPostCreateModalProvider(_r
14
19
  var value = useMemo(function () {
15
20
  return {
16
21
  editViewPayload: editViewPayload,
17
- setEditViewPayload: setEditViewPayload
22
+ setEditViewPayload: setEditViewPayload,
23
+ enableEditView: function enableEditView(enable) {
24
+ _shouldActivateEditView.current = enable;
25
+ },
26
+ shouldActivateEditView: function shouldActivateEditView() {
27
+ return _shouldActivateEditView.current;
28
+ }
18
29
  };
19
30
  }, [editViewPayload, setEditViewPayload]);
20
31
  if (editViewPayload && !active) {
@@ -22,7 +33,7 @@ export var EditPostCreateModalProvider = function EditPostCreateModalProvider(_r
22
33
  }
23
34
  return /*#__PURE__*/React.createElement(EditPostCreateModalContext.Provider, {
24
35
  value: value
25
- }, children);
36
+ }, typeof children === 'function' ? children(value) : children);
26
37
  };
27
38
  export var useEditPostCreateModal = function useEditPostCreateModal() {
28
39
  var value = useContext(EditPostCreateModalContext);
@@ -18,7 +18,7 @@ export var LinkCreatePluginsProvider = function LinkCreatePluginsProvider(_ref)
18
18
  }, [entityKey, plugins]);
19
19
  return /*#__PURE__*/React.createElement(LinkCreatePluginsContext.Provider, {
20
20
  value: value
21
- }, children);
21
+ }, typeof children === 'function' ? children(value) : children);
22
22
  };
23
23
  export var useLinkCreatePlugins = function useLinkCreatePlugins() {
24
24
  var value = useContext(LinkCreatePluginsContext);
@@ -1,14 +1,18 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
1
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  var _excluded = ["submitting"];
4
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
8
  /** @jsx jsx */
6
9
  import { useCallback } from 'react';
7
10
  import { css, jsx } from '@emotion/react';
8
11
  import { Form, FormSpy } from 'react-final-form';
9
12
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
14
  import { Box } from '@atlaskit/primitives';
11
- import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
15
+ import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
12
16
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
13
17
  import { useFormContext } from '../../controllers/form-context';
14
18
  import { CreateFormFooter } from './form-footer';
@@ -19,6 +23,7 @@ var formStyles = css({
19
23
  padding: "0 0 ".concat("var(--ds-space-300, 24px)", " 0"),
20
24
  margin: "var(--ds-space-0, 0px)".concat(" auto")
21
25
  });
26
+ var RESERVED_FIELDS = [LINK_CREATE_FORM_POST_CREATE_FIELD];
22
27
  export var TEST_ID = 'link-create-form';
23
28
  export var CreateForm = function CreateForm(_ref) {
24
29
  var children = _ref.children,
@@ -34,10 +39,11 @@ export var CreateForm = function CreateForm(_ref) {
34
39
  var _useFormContext = useFormContext(),
35
40
  getValidators = _useFormContext.getValidators,
36
41
  formErrorMessage = _useFormContext.formErrorMessage,
37
- setFormDirty = _useFormContext.setFormDirty;
42
+ setFormDirty = _useFormContext.setFormDirty,
43
+ enableEditView = _useFormContext.enableEditView;
38
44
  var handleSubmit = useCallback( /*#__PURE__*/function () {
39
45
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
40
- var validators, errors;
46
+ var validators, errors, shouldEnableEditView, formData;
41
47
  return _regeneratorRuntime.wrap(function _callee$(_context) {
42
48
  while (1) switch (_context.prev = _context.next) {
43
49
  case 0:
@@ -53,8 +59,21 @@ export var CreateForm = function CreateForm(_ref) {
53
59
  }
54
60
  return _context.abrupt("return", errors);
55
61
  case 5:
62
+ if (!getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
63
+ _context.next = 9;
64
+ break;
65
+ }
66
+ shouldEnableEditView = data[LINK_CREATE_FORM_POST_CREATE_FIELD], formData = _objectWithoutProperties(data, [LINK_CREATE_FORM_POST_CREATE_FIELD].map(_toPropertyKey));
67
+ /**
68
+ * If form has post-create field set to trigger post-create edit
69
+ * send this to the form context so we know what to do next
70
+ * if submission is successful
71
+ */
72
+ enableEditView === null || enableEditView === void 0 || enableEditView(!!shouldEnableEditView);
73
+ return _context.abrupt("return", onSubmit(formData));
74
+ case 9:
56
75
  return _context.abrupt("return", onSubmit(data));
57
- case 6:
76
+ case 10:
58
77
  case "end":
59
78
  return _context.stop();
60
79
  }
@@ -63,7 +82,7 @@ export var CreateForm = function CreateForm(_ref) {
63
82
  return function (_x) {
64
83
  return _ref2.apply(this, arguments);
65
84
  };
66
- }(), [createAnalyticsEvent, getValidators, onSubmit]);
85
+ }(), [createAnalyticsEvent, getValidators, onSubmit, enableEditView]);
67
86
  var handleCancel = useCallback(function () {
68
87
  createAnalyticsEvent(createEventPayload('ui.button.clicked.cancel', {})).fire(ANALYTICS_CHANNEL);
69
88
  onCancel && onCancel();
@@ -1,15 +1,24 @@
1
1
  import React from 'react';
2
2
  import Modal, { ModalTransition } from '@atlaskit/modal-dialog';
3
3
  import { useEditPostCreateModal } from '../../../controllers/edit-post-create-context';
4
+ import { useLinkCreatePlugins } from '../../../controllers/plugin-context';
4
5
  export var EditModal = function EditModal(_ref) {
5
- var onClose = _ref.onClose;
6
+ var _activePlugin$editVie;
7
+ var onClose = _ref.onClose,
8
+ onCloseComplete = _ref.onCloseComplete;
6
9
  var _useEditPostCreateMod = useEditPostCreateModal(),
7
10
  editViewPayload = _useEditPostCreateMod.editViewPayload;
11
+ var _useLinkCreatePlugins = useLinkCreatePlugins(),
12
+ activePlugin = _useLinkCreatePlugins.activePlugin;
8
13
  return /*#__PURE__*/React.createElement(ModalTransition, null, !!editViewPayload && /*#__PURE__*/React.createElement(Modal, {
9
14
  testId: "link-create-edit-modal",
10
15
  onClose: onClose,
11
16
  shouldScrollInViewport: true,
12
17
  width: "calc(100vw - 120px)",
13
- height: "calc(100vh - 120px)"
14
- }));
18
+ height: "calc(100vh - 120px)",
19
+ onCloseComplete: onCloseComplete
20
+ }, activePlugin === null || activePlugin === void 0 || (_activePlugin$editVie = activePlugin.editView) === null || _activePlugin$editVie === void 0 ? void 0 : _activePlugin$editVie.call(activePlugin, {
21
+ payload: editViewPayload,
22
+ onClose: onClose
23
+ })));
15
24
  };
@@ -15,7 +15,7 @@ import { Box } from '@atlaskit/primitives';
15
15
  import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
16
16
  import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
17
17
  import { EditPostCreateModalProvider } from '../../controllers/edit-post-create-context';
18
- import { useFormContext, withLinkCreateFormContext } from '../../controllers/form-context';
18
+ import { FormContextProvider, useFormContext } from '../../controllers/form-context';
19
19
  import { LinkCreatePluginsProvider } from '../../controllers/plugin-context';
20
20
  import { ConfirmDismissDialog } from './confirm-dismiss-dialog';
21
21
  import { EditModal } from './edit-modal';
@@ -119,6 +119,7 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref4) {
119
119
  }, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(LinkCreate, _extends({}, createProps, {
120
120
  onCancel: handleCancel
121
121
  }))))), getBooleanFF('platform.linking-platform.link-create.enable-edit') && jsx(EditModal, {
122
+ onCloseComplete: onCloseComplete,
122
123
  onClose: handleCancel
123
124
  }), getBooleanFF('platform.linking-platform.link-create.confirm-dismiss-dialog') && jsx(ConfirmDismissDialog, {
124
125
  active: dismissDialog,
@@ -126,14 +127,60 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref4) {
126
127
  onConfirmDismiss: handleConfirmDismiss
127
128
  }));
128
129
  };
129
- export default withLinkCreateFormContext(function (props) {
130
+ var LinkCreateModalInternal = function LinkCreateModalInternal(props) {
130
131
  if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
131
132
  return jsx(LinkCreatePluginsProvider, {
132
133
  plugins: props.plugins,
133
134
  entityKey: props.entityKey
134
- }, jsx(EditPostCreateModalProvider, {
135
- active: !!props.active
136
- }, jsx(LinkCreateWithModal, props)));
135
+ }, function (pluginsProvider) {
136
+ return jsx(EditPostCreateModalProvider, {
137
+ active: !!props.active
138
+ }, function (_ref5) {
139
+ var _pluginsProvider$acti;
140
+ var setEditViewPayload = _ref5.setEditViewPayload,
141
+ editViewPayload = _ref5.editViewPayload,
142
+ shouldActivateEditView = _ref5.shouldActivateEditView,
143
+ enableEditView = _ref5.enableEditView;
144
+ return jsx(FormContextProvider, {
145
+ enableEditView: pluginsProvider !== null && pluginsProvider !== void 0 && (_pluginsProvider$acti = pluginsProvider.activePlugin) !== null && _pluginsProvider$acti !== void 0 && _pluginsProvider$acti.editView ? enableEditView : undefined
146
+ }, jsx(LinkCreateWithModal, _extends({}, props, {
147
+ active: props.active && !editViewPayload,
148
+ onCreate: /*#__PURE__*/function () {
149
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(payload) {
150
+ var _props$onCreate;
151
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
152
+ while (1) switch (_context2.prev = _context2.next) {
153
+ case 0:
154
+ _context2.next = 2;
155
+ return (_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload);
156
+ case 2:
157
+ // if onComplete exists then there is an edit flow
158
+ if (props.onComplete) {
159
+ if (shouldActivateEditView()) {
160
+ //edit button is pressed
161
+ setEditViewPayload(payload);
162
+ } else {
163
+ //create button is pressed
164
+ props.onComplete();
165
+ }
166
+ }
167
+ case 3:
168
+ case "end":
169
+ return _context2.stop();
170
+ }
171
+ }, _callee2);
172
+ }));
173
+ return function (_x2) {
174
+ return _ref6.apply(this, arguments);
175
+ };
176
+ }()
177
+ })));
178
+ });
179
+ });
137
180
  }
138
- return jsx(LinkCreateWithModal, props);
139
- });
181
+ return jsx(FormContextProvider, null, jsx(LinkCreateWithModal, props));
182
+ };
183
+ var LinkCreateModalPublic = function LinkCreateModalPublic(props) {
184
+ return jsx(LinkCreateModalInternal, props);
185
+ };
186
+ export default LinkCreateModalPublic;
@@ -27,7 +27,7 @@ var LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__
27
27
  }));
28
28
  export var PACKAGE_DATA = {
29
29
  packageName: "@atlaskit/link-create" || '',
30
- packageVersion: "1.5.1" || '',
30
+ packageVersion: "1.6.0" || '',
31
31
  componentName: COMPONENT_NAME,
32
32
  source: COMPONENT_NAME
33
33
  };
@@ -22,6 +22,16 @@ export interface Group {
22
22
  */
23
23
  key: string;
24
24
  }
25
+ export type EditViewProps = {
26
+ /**
27
+ * The payload returned from the create function
28
+ */
29
+ payload: CreatePayload;
30
+ /**
31
+ * Function for the plugin to call when it signals to be closed
32
+ */
33
+ onClose: () => void;
34
+ };
25
35
  export interface LinkCreatePlugin {
26
36
  /**
27
37
  * The Group that this plugin entity belongs to
@@ -43,6 +53,10 @@ export interface LinkCreatePlugin {
43
53
  * A renderer function to render the form
44
54
  */
45
55
  form: ReactNode;
56
+ /**
57
+ * The post create edit view to be rendered after edit button is clicked.
58
+ */
59
+ editView?: ({ payload, onClose }: EditViewProps) => JSX.Element;
46
60
  }
47
61
  /** The object that is returned on successful callback of create function*/
48
62
  export type CreatePayload = {
@@ -1,12 +1,32 @@
1
1
  import React from 'react';
2
2
  import { CreatePayload } from '../../common/types';
3
3
  type EditPostCreateModalContextValue = {
4
+ /**
5
+ * The created object that is current being editted in the post-create flow
6
+ */
4
7
  editViewPayload?: CreatePayload | undefined;
8
+ /**
9
+ * Sets the object to be editted in the post-create edit flow
10
+ */
5
11
  setEditViewPayload: (payload?: CreatePayload) => void;
12
+ /**
13
+ * Callback to tell link create to trigger post-create edit flow after
14
+ * an object is created
15
+ */
16
+ enableEditView: (enable: boolean) => void;
17
+ /**
18
+ * Returns whether or not the edit view should be activated on next object creation
19
+ */
20
+ shouldActivateEditView: () => boolean;
6
21
  };
7
- export declare const EditPostCreateModalProvider: ({ active, children, }: {
22
+ type EditPostCreateModalProviderProps = {
23
+ /**
24
+ * The value of the top-level link create props that indicates control
25
+ * of whether the experience should be currently active
26
+ */
8
27
  active: boolean;
9
- children: React.ReactNode;
10
- }) => JSX.Element;
28
+ children: React.ReactNode | ((value: EditPostCreateModalContextValue) => React.ReactNode);
29
+ };
30
+ export declare const EditPostCreateModalProvider: ({ active, children, }: EditPostCreateModalProviderProps) => JSX.Element;
11
31
  export declare const useEditPostCreateModal: () => EditPostCreateModalContextValue;
12
32
  export {};
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
  import { LinkCreatePlugin } from '../../common/types';
3
+ type LinkCreatePluginsContextValue = {
4
+ activePlugin: LinkCreatePlugin | null;
5
+ } | null;
3
6
  type LinkCreatePluginsProviderProps = {
4
7
  /**
5
8
  * The list of plugins provided as a prop to Link Create component
@@ -9,7 +12,7 @@ type LinkCreatePluginsProviderProps = {
9
12
  * The entity key as provided as prop to link create which controls the initially active plugin
10
13
  */
11
14
  entityKey: string;
12
- children: React.ReactNode;
15
+ children: React.ReactNode | ((value: LinkCreatePluginsContextValue) => React.ReactNode);
13
16
  };
14
17
  export declare const LinkCreatePluginsProvider: ({ plugins, entityKey: propEntityKey, children, }: LinkCreatePluginsProviderProps) => JSX.Element;
15
18
  export declare const useLinkCreatePlugins: () => {
@@ -1,14 +1,30 @@
1
1
  /** @jsx jsx */
2
2
  import { ReactNode } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
+ type ReservedFields = {
5
+ [Field in (typeof RESERVED_FIELDS)[number]]?: unknown;
6
+ };
7
+ declare const RESERVED_FIELDS: readonly ["__post_create__"];
8
+ type DisallowReservedFields<T> = T & {
9
+ [Field in (typeof RESERVED_FIELDS)[number]]?: never;
10
+ };
11
+ type OmitReservedFields<T> = Omit<T, keyof ReservedFields>;
4
12
  export interface CreateFormProps<FormData> {
5
13
  children: ReactNode;
6
14
  testId?: string;
7
- onSubmit: (data: FormData) => void;
15
+ onSubmit: (data: OmitReservedFields<FormData>) => void;
8
16
  onCancel?: () => void;
9
17
  isLoading?: boolean;
18
+ /**
19
+ * Hides the rendering of the footer buttons
20
+ */
10
21
  hideFooter?: boolean;
11
- initialValues?: FormData;
22
+ /**
23
+ * Values to initialise the forms initial state with
24
+ * Should not include values for reserved fields
25
+ */
26
+ initialValues?: DisallowReservedFields<FormData>;
12
27
  }
13
28
  export declare const TEST_ID = "link-create-form";
14
29
  export declare const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, initialValues, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
30
+ export {};
@@ -1,4 +1,8 @@
1
- /// <reference types="react" />
2
- export declare const EditModal: ({ onClose }: {
3
- onClose?: (() => void) | undefined;
4
- }) => JSX.Element;
1
+ import React from 'react';
2
+ import Modal from '@atlaskit/modal-dialog';
3
+ type EditModalProps = {
4
+ onClose: () => void;
5
+ onCloseComplete?: React.ComponentProps<typeof Modal>['onCloseComplete'];
6
+ };
7
+ export declare const EditModal: ({ onClose, onCloseComplete }: EditModalProps) => JSX.Element;
8
+ export {};
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import { jsx } from '@emotion/react';
2
2
  import { LinkCreateWithModalProps } from '../../common/types';
3
3
  export declare const TEST_ID = "link-create";
4
- declare const _default: (props: LinkCreateWithModalProps) => JSX.Element;
5
- export default _default;
4
+ declare const LinkCreateModalPublic: (props: LinkCreateWithModalProps) => jsx.JSX.Element;
5
+ export default LinkCreateModalPublic;
@@ -22,6 +22,16 @@ export interface Group {
22
22
  */
23
23
  key: string;
24
24
  }
25
+ export type EditViewProps = {
26
+ /**
27
+ * The payload returned from the create function
28
+ */
29
+ payload: CreatePayload;
30
+ /**
31
+ * Function for the plugin to call when it signals to be closed
32
+ */
33
+ onClose: () => void;
34
+ };
25
35
  export interface LinkCreatePlugin {
26
36
  /**
27
37
  * The Group that this plugin entity belongs to
@@ -43,6 +53,10 @@ export interface LinkCreatePlugin {
43
53
  * A renderer function to render the form
44
54
  */
45
55
  form: ReactNode;
56
+ /**
57
+ * The post create edit view to be rendered after edit button is clicked.
58
+ */
59
+ editView?: ({ payload, onClose }: EditViewProps) => JSX.Element;
46
60
  }
47
61
  /** The object that is returned on successful callback of create function*/
48
62
  export type CreatePayload = {
@@ -1,12 +1,32 @@
1
1
  import React from 'react';
2
2
  import { CreatePayload } from '../../common/types';
3
3
  type EditPostCreateModalContextValue = {
4
+ /**
5
+ * The created object that is current being editted in the post-create flow
6
+ */
4
7
  editViewPayload?: CreatePayload | undefined;
8
+ /**
9
+ * Sets the object to be editted in the post-create edit flow
10
+ */
5
11
  setEditViewPayload: (payload?: CreatePayload) => void;
12
+ /**
13
+ * Callback to tell link create to trigger post-create edit flow after
14
+ * an object is created
15
+ */
16
+ enableEditView: (enable: boolean) => void;
17
+ /**
18
+ * Returns whether or not the edit view should be activated on next object creation
19
+ */
20
+ shouldActivateEditView: () => boolean;
6
21
  };
7
- export declare const EditPostCreateModalProvider: ({ active, children, }: {
22
+ type EditPostCreateModalProviderProps = {
23
+ /**
24
+ * The value of the top-level link create props that indicates control
25
+ * of whether the experience should be currently active
26
+ */
8
27
  active: boolean;
9
- children: React.ReactNode;
10
- }) => JSX.Element;
28
+ children: React.ReactNode | ((value: EditPostCreateModalContextValue) => React.ReactNode);
29
+ };
30
+ export declare const EditPostCreateModalProvider: ({ active, children, }: EditPostCreateModalProviderProps) => JSX.Element;
11
31
  export declare const useEditPostCreateModal: () => EditPostCreateModalContextValue;
12
32
  export {};
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
  import { LinkCreatePlugin } from '../../common/types';
3
+ type LinkCreatePluginsContextValue = {
4
+ activePlugin: LinkCreatePlugin | null;
5
+ } | null;
3
6
  type LinkCreatePluginsProviderProps = {
4
7
  /**
5
8
  * The list of plugins provided as a prop to Link Create component
@@ -9,7 +12,7 @@ type LinkCreatePluginsProviderProps = {
9
12
  * The entity key as provided as prop to link create which controls the initially active plugin
10
13
  */
11
14
  entityKey: string;
12
- children: React.ReactNode;
15
+ children: React.ReactNode | ((value: LinkCreatePluginsContextValue) => React.ReactNode);
13
16
  };
14
17
  export declare const LinkCreatePluginsProvider: ({ plugins, entityKey: propEntityKey, children, }: LinkCreatePluginsProviderProps) => JSX.Element;
15
18
  export declare const useLinkCreatePlugins: () => {
@@ -1,14 +1,32 @@
1
1
  /** @jsx jsx */
2
2
  import { ReactNode } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
+ type ReservedFields = {
5
+ [Field in (typeof RESERVED_FIELDS)[number]]?: unknown;
6
+ };
7
+ declare const RESERVED_FIELDS: readonly [
8
+ "__post_create__"
9
+ ];
10
+ type DisallowReservedFields<T> = T & {
11
+ [Field in (typeof RESERVED_FIELDS)[number]]?: never;
12
+ };
13
+ type OmitReservedFields<T> = Omit<T, keyof ReservedFields>;
4
14
  export interface CreateFormProps<FormData> {
5
15
  children: ReactNode;
6
16
  testId?: string;
7
- onSubmit: (data: FormData) => void;
17
+ onSubmit: (data: OmitReservedFields<FormData>) => void;
8
18
  onCancel?: () => void;
9
19
  isLoading?: boolean;
20
+ /**
21
+ * Hides the rendering of the footer buttons
22
+ */
10
23
  hideFooter?: boolean;
11
- initialValues?: FormData;
24
+ /**
25
+ * Values to initialise the forms initial state with
26
+ * Should not include values for reserved fields
27
+ */
28
+ initialValues?: DisallowReservedFields<FormData>;
12
29
  }
13
30
  export declare const TEST_ID = "link-create-form";
14
31
  export declare const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, initialValues, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
32
+ export {};
@@ -1,4 +1,8 @@
1
- /// <reference types="react" />
2
- export declare const EditModal: ({ onClose }: {
3
- onClose?: (() => void) | undefined;
4
- }) => JSX.Element;
1
+ import React from 'react';
2
+ import Modal from '@atlaskit/modal-dialog';
3
+ type EditModalProps = {
4
+ onClose: () => void;
5
+ onCloseComplete?: React.ComponentProps<typeof Modal>['onCloseComplete'];
6
+ };
7
+ export declare const EditModal: ({ onClose, onCloseComplete }: EditModalProps) => JSX.Element;
8
+ export {};
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import { jsx } from '@emotion/react';
2
2
  import { LinkCreateWithModalProps } from '../../common/types';
3
3
  export declare const TEST_ID = "link-create";
4
- declare const _default: (props: LinkCreateWithModalProps) => JSX.Element;
5
- export default _default;
4
+ declare const LinkCreateModalPublic: (props: LinkCreateWithModalProps) => jsx.JSX.Element;
5
+ export default LinkCreateModalPublic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "The driver component of meta creation flow",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
package/report.api.md CHANGED
@@ -83,16 +83,14 @@ export function CreateFormLoader({
83
83
  export interface CreateFormProps<FormData> {
84
84
  // (undocumented)
85
85
  children: ReactNode;
86
- // (undocumented)
87
86
  hideFooter?: boolean;
88
- // (undocumented)
89
- initialValues?: FormData;
87
+ initialValues?: DisallowReservedFields<FormData>;
90
88
  // (undocumented)
91
89
  isLoading?: boolean;
92
90
  // (undocumented)
93
91
  onCancel?: () => void;
94
92
  // (undocumented)
95
- onSubmit: (data: FormData) => void;
93
+ onSubmit: (data: OmitReservedFields<FormData>) => void;
96
94
  // (undocumented)
97
95
  testId?: string;
98
96
  }
@@ -106,6 +104,17 @@ export type CreatePayload = {
106
104
  data?: Record<string, unknown>;
107
105
  };
108
106
 
107
+ // @public (undocumented)
108
+ type DisallowReservedFields<T> = T & {
109
+ [Field in (typeof RESERVED_FIELDS)[number]]?: never;
110
+ };
111
+
112
+ // @public (undocumented)
113
+ type EditViewProps = {
114
+ payload: CreatePayload;
115
+ onClose: () => void;
116
+ };
117
+
109
118
  // @public
110
119
  export const FormSpy: <T extends Record<string, unknown>>({
111
120
  children,
@@ -135,6 +144,7 @@ interface LinkCreateCallbackProviderProps {
135
144
 
136
145
  // @public (undocumented)
137
146
  export interface LinkCreatePlugin {
147
+ editView?: ({ payload, onClose }: EditViewProps) => JSX.Element;
138
148
  form: ReactNode;
139
149
  group: Group;
140
150
  icon: string;
@@ -163,6 +173,17 @@ export interface LinkCreateWithModalProps
163
173
  modalTitle?: string;
164
174
  }
165
175
 
176
+ // @public (undocumented)
177
+ type OmitReservedFields<T> = Omit<T, keyof ReservedFields>;
178
+
179
+ // @public (undocumented)
180
+ const RESERVED_FIELDS: readonly ['__post_create__'];
181
+
182
+ // @public (undocumented)
183
+ type ReservedFields = {
184
+ [Field in (typeof RESERVED_FIELDS)[number]]?: unknown;
185
+ };
186
+
166
187
  // @public
167
188
  export function Select<T = OptionType>({
168
189
  id,
@@ -46,16 +46,14 @@ export function CreateFormLoader({ size }: Partial<SpinnerProps>): jsx.JSX.Eleme
46
46
  export interface CreateFormProps<FormData> {
47
47
  // (undocumented)
48
48
  children: ReactNode;
49
- // (undocumented)
50
49
  hideFooter?: boolean;
51
- // (undocumented)
52
- initialValues?: FormData;
50
+ initialValues?: DisallowReservedFields<FormData>;
53
51
  // (undocumented)
54
52
  isLoading?: boolean;
55
53
  // (undocumented)
56
54
  onCancel?: () => void;
57
55
  // (undocumented)
58
- onSubmit: (data: FormData) => void;
56
+ onSubmit: (data: OmitReservedFields<FormData>) => void;
59
57
  // (undocumented)
60
58
  testId?: string;
61
59
  }
@@ -69,6 +67,17 @@ export type CreatePayload = {
69
67
  data?: Record<string, unknown>;
70
68
  };
71
69
 
70
+ // @public (undocumented)
71
+ type DisallowReservedFields<T> = T & {
72
+ [Field in (typeof RESERVED_FIELDS)[number]]?: never;
73
+ };
74
+
75
+ // @public (undocumented)
76
+ type EditViewProps = {
77
+ payload: CreatePayload;
78
+ onClose: () => void;
79
+ };
80
+
72
81
  // @public
73
82
  export const FormSpy: <T extends Record<string, unknown>>({ children, }: FormSpyProps<T>) => JSX.Element;
74
83
 
@@ -98,6 +107,7 @@ interface LinkCreateCallbackProviderProps {
98
107
 
99
108
  // @public (undocumented)
100
109
  export interface LinkCreatePlugin {
110
+ editView?: ({ payload, onClose }: EditViewProps) => JSX.Element;
101
111
  form: ReactNode;
102
112
  group: Group;
103
113
  icon: string;
@@ -124,6 +134,17 @@ export interface LinkCreateWithModalProps extends LinkCreateProps, Partial<Pick<
124
134
  modalTitle?: string;
125
135
  }
126
136
 
137
+ // @public (undocumented)
138
+ type OmitReservedFields<T> = Omit<T, keyof ReservedFields>;
139
+
140
+ // @public (undocumented)
141
+ const RESERVED_FIELDS: readonly ["__post_create__"];
142
+
143
+ // @public (undocumented)
144
+ type ReservedFields = {
145
+ [Field in (typeof RESERVED_FIELDS)[number]]?: unknown;
146
+ };
147
+
127
148
  // @public
128
149
  export function Select<T = OptionType>({ id, name, label, isRequired, validators, validationHelpText, testId, ...restProps }: SelectProps<T>): jsx.JSX.Element;
129
150