@atlaskit/link-create 1.5.0 → 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 (83) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/analytics.spec.yaml +14 -0
  3. package/dist/cjs/common/ui/Button/index.js +37 -0
  4. package/dist/cjs/common/ui/error-boundary-modal/index.js +30 -0
  5. package/dist/cjs/common/utils/analytics/analytics.codegen.js +1 -1
  6. package/dist/cjs/common/utils/analytics/components.js +20 -0
  7. package/dist/cjs/controllers/edit-post-create-context/index.js +14 -3
  8. package/dist/cjs/controllers/plugin-context/index.js +1 -1
  9. package/dist/cjs/ui/create-form/main.js +24 -6
  10. package/dist/cjs/ui/link-create/confirm-dismiss-dialog/main.js +18 -5
  11. package/dist/cjs/ui/link-create/edit-modal/index.js +12 -3
  12. package/dist/cjs/ui/link-create/error-boundary/error-boundary-base/index.js +4 -7
  13. package/dist/cjs/ui/link-create/error-boundary/index.js +4 -3
  14. package/dist/cjs/ui/link-create/main.js +53 -6
  15. package/dist/cjs/ui/main.js +12 -1
  16. package/dist/es2019/common/ui/Button/index.js +27 -0
  17. package/dist/es2019/common/ui/error-boundary-modal/index.js +22 -0
  18. package/dist/es2019/common/utils/analytics/analytics.codegen.js +1 -1
  19. package/dist/es2019/common/utils/analytics/components.js +15 -0
  20. package/dist/es2019/controllers/edit-post-create-context/index.js +11 -4
  21. package/dist/es2019/controllers/plugin-context/index.js +1 -1
  22. package/dist/es2019/ui/create-form/main.js +20 -3
  23. package/dist/es2019/ui/link-create/confirm-dismiss-dialog/main.js +17 -4
  24. package/dist/es2019/ui/link-create/edit-modal/index.js +13 -3
  25. package/dist/es2019/ui/link-create/error-boundary/error-boundary-base/index.js +4 -4
  26. package/dist/es2019/ui/link-create/error-boundary/index.js +4 -3
  27. package/dist/es2019/ui/link-create/main.js +38 -6
  28. package/dist/es2019/ui/main.js +12 -1
  29. package/dist/esm/common/ui/Button/index.js +27 -0
  30. package/dist/esm/common/ui/error-boundary-modal/index.js +21 -0
  31. package/dist/esm/common/utils/analytics/analytics.codegen.js +1 -1
  32. package/dist/esm/common/utils/analytics/components.js +13 -0
  33. package/dist/esm/controllers/edit-post-create-context/index.js +15 -4
  34. package/dist/esm/controllers/plugin-context/index.js +1 -1
  35. package/dist/esm/ui/create-form/main.js +24 -5
  36. package/dist/esm/ui/link-create/confirm-dismiss-dialog/main.js +17 -4
  37. package/dist/esm/ui/link-create/edit-modal/index.js +12 -3
  38. package/dist/esm/ui/link-create/error-boundary/error-boundary-base/index.js +4 -4
  39. package/dist/esm/ui/link-create/error-boundary/index.js +4 -3
  40. package/dist/esm/ui/link-create/main.js +54 -7
  41. package/dist/esm/ui/main.js +12 -1
  42. package/dist/types/common/types.d.ts +14 -0
  43. package/dist/types/common/ui/Button/index.d.ts +5 -0
  44. package/dist/types/common/ui/error-boundary-modal/index.d.ts +11 -0
  45. package/dist/types/common/utils/analytics/analytics.codegen.d.ts +6 -2
  46. package/dist/types/common/utils/analytics/components.d.ts +8 -0
  47. package/dist/types/controllers/edit-post-create-context/index.d.ts +23 -3
  48. package/dist/types/controllers/plugin-context/index.d.ts +4 -1
  49. package/dist/types/ui/create-form/main.d.ts +18 -2
  50. package/dist/types/ui/link-create/edit-modal/index.d.ts +8 -4
  51. package/dist/types/ui/link-create/error-boundary/error-boundary-base/index.d.ts +3 -3
  52. package/dist/types/ui/link-create/error-boundary/index.d.ts +5 -1
  53. package/dist/types/ui/link-create/main.d.ts +3 -3
  54. package/dist/types-ts4.5/common/types.d.ts +14 -0
  55. package/dist/types-ts4.5/common/ui/Button/index.d.ts +5 -0
  56. package/dist/types-ts4.5/common/ui/error-boundary-modal/index.d.ts +11 -0
  57. package/dist/types-ts4.5/common/utils/analytics/analytics.codegen.d.ts +6 -2
  58. package/dist/types-ts4.5/common/utils/analytics/components.d.ts +8 -0
  59. package/dist/types-ts4.5/controllers/edit-post-create-context/index.d.ts +23 -3
  60. package/dist/types-ts4.5/controllers/plugin-context/index.d.ts +4 -1
  61. package/dist/types-ts4.5/ui/create-form/main.d.ts +20 -2
  62. package/dist/types-ts4.5/ui/link-create/edit-modal/index.d.ts +8 -4
  63. package/dist/types-ts4.5/ui/link-create/error-boundary/error-boundary-base/index.d.ts +3 -3
  64. package/dist/types-ts4.5/ui/link-create/error-boundary/index.d.ts +5 -1
  65. package/dist/types-ts4.5/ui/link-create/main.d.ts +3 -3
  66. package/package.json +6 -3
  67. package/report.api.md +25 -4
  68. package/tmp/api-report-tmp.d.ts +25 -4
  69. /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
  70. /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
  71. /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
  72. /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
  73. /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
  74. /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
  75. /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
  76. /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
  77. /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
  78. /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.d.ts +0 -0
  79. /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.d.ts +0 -0
  80. /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.d.ts +0 -0
  81. /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.d.ts +0 -0
  82. /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.d.ts +0 -0
  83. /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.d.ts +0 -0
@@ -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;
@@ -5,18 +5,29 @@ import { memo } from 'react';
5
5
  import { jsx } from '@emotion/react';
6
6
  import { AnalyticsContext } from '@atlaskit/analytics-next';
7
7
  import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { COMPONENT_NAME } from '../common/constants';
10
+ import { ErrorBoundaryModal } from '../common/ui/error-boundary-modal';
9
11
  import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
10
12
  import { fetchMessagesForLocale } from '../common/utils/locale/fetch-messages-for-locale';
11
13
  import i18nEN from '../i18n/en';
12
14
  import LinkCreate from './link-create';
15
+ import { ErrorBoundary } from './link-create/error-boundary';
13
16
  var LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(function (_ref) {
14
17
  var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
18
+ if (getBooleanFF('platform.linking-platform.link-create.outer-error-boundary')) {
19
+ return jsx(ErrorBoundary, {
20
+ errorComponent: jsx(ErrorBoundaryModal, {
21
+ active: props.active,
22
+ onClose: props.onCancel
23
+ })
24
+ }, jsx(LinkCreate, props));
25
+ }
15
26
  return jsx(LinkCreate, props);
16
27
  }));
17
28
  export var PACKAGE_DATA = {
18
29
  packageName: "@atlaskit/link-create" || '',
19
- packageVersion: "1.5.0" || '',
30
+ packageVersion: "1.6.0" || '',
20
31
  componentName: COMPONENT_NAME,
21
32
  source: COMPONENT_NAME
22
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 = {
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { AnalyticsEventAttributes } from '../../../common/utils/analytics/analytics.codegen';
3
+ export declare const Button: React.ForwardRefExoticComponent<Pick<import("@atlaskit/button").ButtonProps & React.RefAttributes<HTMLElement> & {
4
+ actionSubjectId: "create" | "cancel" | "confirm";
5
+ }, "key" | keyof import("@atlaskit/button").ButtonProps | "actionSubjectId"> & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * ErrorBoundaryModal props are the same as those passed to LinkCreate, which
4
+ * are used to control its active state
5
+ */
6
+ type ErrorBoundaryModalProps = {
7
+ active?: boolean;
8
+ onClose?: () => void;
9
+ };
10
+ export declare const ErrorBoundaryModal: React.FC<ErrorBoundaryModalProps>;
11
+ export {};
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::afcb2b69ebf56a35a2926fa7fdfd1118>>
6
+ * @codegen <<SignedSource::af0139619517f37a8bca32ddb6b7d6e0>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
8
8
  */
9
9
  export type PackageMetaDataType = {
@@ -18,8 +18,10 @@ export type LinkCreateAnalyticsContextType = {
18
18
  appearance: 'modal' | 'popup';
19
19
  };
20
20
  export type LinkCreateScreenViewedAttributesType = {};
21
+ export type LinkCreateExitWarningScreenViewedAttributesType = {};
21
22
  export type ButtonClickedCreateAttributesType = {};
22
23
  export type ButtonClickedCancelAttributesType = {};
24
+ export type ButtonClickedConfirmAttributesType = {};
23
25
  export type ModalDialogClosedLinkCreateAttributesType = {};
24
26
  export type LinkCreateUnhandledErrorCaughtAttributesType = {
25
27
  browserInfo: string;
@@ -33,10 +35,12 @@ export type ObjectCreatedLinkCreateAttributesType = {
33
35
  export type ObjectCreateFailedLinkCreateAttributesType = {
34
36
  failureType: string;
35
37
  };
36
- type AnalyticsEventAttributes = {
38
+ export type AnalyticsEventAttributes = {
37
39
  'screen.linkCreateScreen.viewed': LinkCreateScreenViewedAttributesType;
40
+ 'screen.linkCreateExitWarningScreen.viewed': LinkCreateExitWarningScreenViewedAttributesType;
38
41
  'ui.button.clicked.create': ButtonClickedCreateAttributesType;
39
42
  'ui.button.clicked.cancel': ButtonClickedCancelAttributesType;
43
+ 'ui.button.clicked.confirm': ButtonClickedConfirmAttributesType;
40
44
  'ui.modalDialog.closed.linkCreate': ModalDialogClosedLinkCreateAttributesType;
41
45
  'operational.linkCreate.unhandledErrorCaught': LinkCreateUnhandledErrorCaughtAttributesType;
42
46
  'track.object.created.linkCreate': ObjectCreatedLinkCreateAttributesType;
@@ -0,0 +1,8 @@
1
+ import { AnalyticsEventAttributes } from './analytics.codegen';
2
+ type ScreenViewedEventProps = {
3
+ screen: keyof {
4
+ [Key in keyof AnalyticsEventAttributes as Key extends `screen.${infer ScreenName}.viewed` ? ScreenName : never]: any;
5
+ };
6
+ };
7
+ export declare const ScreenViewedEvent: ({ screen }: ScreenViewedEventProps) => null;
8
+ export {};
@@ -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,4 +1,4 @@
1
- import React, { Component, ReactNode } from 'react';
1
+ import { Component, ReactNode } from 'react';
2
2
  export type ErrorBoundaryErrorInfo = {
3
3
  componentStack: string;
4
4
  };
@@ -7,12 +7,12 @@ type BaseErrorBoundaryState = {
7
7
  };
8
8
  interface BaseErrorBoundaryProps {
9
9
  children: ReactNode;
10
- ErrorComponent?: React.ComponentType;
10
+ errorComponent?: JSX.Element;
11
11
  onError?: (error: Error, info?: ErrorBoundaryErrorInfo) => void;
12
12
  }
13
13
  export declare class BaseErrorBoundary extends Component<BaseErrorBoundaryProps, BaseErrorBoundaryState> {
14
14
  constructor(props: BaseErrorBoundaryProps);
15
15
  componentDidCatch(error: Error, info?: ErrorBoundaryErrorInfo): void;
16
- render(): React.ReactNode;
16
+ render(): ReactNode;
17
17
  }
18
18
  export {};
@@ -1,2 +1,6 @@
1
1
  import React from 'react';
2
- export declare const ErrorBoundary: React.FC<{}>;
2
+ type ErrorBoundaryProps = {
3
+ errorComponent?: JSX.Element;
4
+ };
5
+ export declare const ErrorBoundary: React.FC<ErrorBoundaryProps>;
6
+ 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 = {
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { AnalyticsEventAttributes } from '../../../common/utils/analytics/analytics.codegen';
3
+ export declare const Button: React.ForwardRefExoticComponent<Pick<import("@atlaskit/button").ButtonProps & React.RefAttributes<HTMLElement> & {
4
+ actionSubjectId: "create" | "cancel" | "confirm";
5
+ }, "key" | keyof import("@atlaskit/button").ButtonProps | "actionSubjectId"> & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * ErrorBoundaryModal props are the same as those passed to LinkCreate, which
4
+ * are used to control its active state
5
+ */
6
+ type ErrorBoundaryModalProps = {
7
+ active?: boolean;
8
+ onClose?: () => void;
9
+ };
10
+ export declare const ErrorBoundaryModal: React.FC<ErrorBoundaryModalProps>;
11
+ export {};
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::afcb2b69ebf56a35a2926fa7fdfd1118>>
6
+ * @codegen <<SignedSource::af0139619517f37a8bca32ddb6b7d6e0>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
8
8
  */
9
9
  export type PackageMetaDataType = {
@@ -18,8 +18,10 @@ export type LinkCreateAnalyticsContextType = {
18
18
  appearance: 'modal' | 'popup';
19
19
  };
20
20
  export type LinkCreateScreenViewedAttributesType = {};
21
+ export type LinkCreateExitWarningScreenViewedAttributesType = {};
21
22
  export type ButtonClickedCreateAttributesType = {};
22
23
  export type ButtonClickedCancelAttributesType = {};
24
+ export type ButtonClickedConfirmAttributesType = {};
23
25
  export type ModalDialogClosedLinkCreateAttributesType = {};
24
26
  export type LinkCreateUnhandledErrorCaughtAttributesType = {
25
27
  browserInfo: string;
@@ -33,10 +35,12 @@ export type ObjectCreatedLinkCreateAttributesType = {
33
35
  export type ObjectCreateFailedLinkCreateAttributesType = {
34
36
  failureType: string;
35
37
  };
36
- type AnalyticsEventAttributes = {
38
+ export type AnalyticsEventAttributes = {
37
39
  'screen.linkCreateScreen.viewed': LinkCreateScreenViewedAttributesType;
40
+ 'screen.linkCreateExitWarningScreen.viewed': LinkCreateExitWarningScreenViewedAttributesType;
38
41
  'ui.button.clicked.create': ButtonClickedCreateAttributesType;
39
42
  'ui.button.clicked.cancel': ButtonClickedCancelAttributesType;
43
+ 'ui.button.clicked.confirm': ButtonClickedConfirmAttributesType;
40
44
  'ui.modalDialog.closed.linkCreate': ModalDialogClosedLinkCreateAttributesType;
41
45
  'operational.linkCreate.unhandledErrorCaught': LinkCreateUnhandledErrorCaughtAttributesType;
42
46
  'track.object.created.linkCreate': ObjectCreatedLinkCreateAttributesType;
@@ -0,0 +1,8 @@
1
+ import { AnalyticsEventAttributes } from './analytics.codegen';
2
+ type ScreenViewedEventProps = {
3
+ screen: keyof {
4
+ [Key in keyof AnalyticsEventAttributes as Key extends `screen.${infer ScreenName}.viewed` ? ScreenName : never]: any;
5
+ };
6
+ };
7
+ export declare const ScreenViewedEvent: ({ screen }: ScreenViewedEventProps) => null;
8
+ export {};
@@ -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,4 +1,4 @@
1
- import React, { Component, ReactNode } from 'react';
1
+ import { Component, ReactNode } from 'react';
2
2
  export type ErrorBoundaryErrorInfo = {
3
3
  componentStack: string;
4
4
  };
@@ -7,12 +7,12 @@ type BaseErrorBoundaryState = {
7
7
  };
8
8
  interface BaseErrorBoundaryProps {
9
9
  children: ReactNode;
10
- ErrorComponent?: React.ComponentType;
10
+ errorComponent?: JSX.Element;
11
11
  onError?: (error: Error, info?: ErrorBoundaryErrorInfo) => void;
12
12
  }
13
13
  export declare class BaseErrorBoundary extends Component<BaseErrorBoundaryProps, BaseErrorBoundaryState> {
14
14
  constructor(props: BaseErrorBoundaryProps);
15
15
  componentDidCatch(error: Error, info?: ErrorBoundaryErrorInfo): void;
16
- render(): React.ReactNode;
16
+ render(): ReactNode;
17
17
  }
18
18
  export {};
@@ -1,2 +1,6 @@
1
1
  import React from 'react';
2
- export declare const ErrorBoundary: React.FC<{}>;
2
+ type ErrorBoundaryProps = {
3
+ errorComponent?: JSX.Element;
4
+ };
5
+ export declare const ErrorBoundary: React.FC<ErrorBoundaryProps>;
6
+ 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.0",
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",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@atlaskit/analytics-next": "^9.1.0",
38
- "@atlaskit/button": "^16.12.0",
38
+ "@atlaskit/button": "^16.13.0",
39
39
  "@atlaskit/empty-state": "^7.6.0",
40
40
  "@atlaskit/form": "^8.11.0",
41
41
  "@atlaskit/icon": "^21.12.0",
42
42
  "@atlaskit/intl-messages-provider": "^1.0.0",
43
43
  "@atlaskit/modal-dialog": "^12.8.0",
44
44
  "@atlaskit/platform-feature-flags": "^0.2.1",
45
- "@atlaskit/primitives": "^1.6.0",
45
+ "@atlaskit/primitives": "^1.9.0",
46
46
  "@atlaskit/select": "^16.7.0",
47
47
  "@atlaskit/spinner": "^15.6.0",
48
48
  "@atlaskit/textfield": "^5.6.0",
@@ -117,6 +117,9 @@
117
117
  },
118
118
  "platform.linking-platform.link-create.confirm-dismiss-dialog": {
119
119
  "type": "boolean"
120
+ },
121
+ "platform.linking-platform.link-create.outer-error-boundary": {
122
+ "type": "boolean"
120
123
  }
121
124
  }
122
125
  }