@atlaskit/link-create 2.4.0 → 2.5.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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/common/constants.js +1 -1
- package/dist/cjs/common/ui/error-boundary-modal/index.js +1 -0
- package/dist/cjs/common/ui/error-boundary-ui/error-svg/index.js +1 -0
- package/dist/cjs/controllers/create-field/main.js +1 -1
- package/dist/cjs/controllers/exit-warning-modal-context/index.js +41 -4
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/ui/create-form/async-select/main.js +1 -0
- package/dist/cjs/ui/create-form/form-footer/main.js +1 -0
- package/dist/cjs/ui/create-form/form-loader/main.js +2 -0
- package/dist/cjs/ui/create-form/main.js +2 -1
- package/dist/cjs/ui/create-form/select/main.js +1 -0
- package/dist/cjs/ui/create-form/textfield/main.js +1 -0
- package/dist/cjs/ui/create-form/user-picker/main.js +1 -0
- package/dist/cjs/ui/inline-create/index.js +2 -0
- package/dist/cjs/ui/inline-create/main.js +19 -29
- package/dist/cjs/ui/modal-create/index.js +2 -0
- package/dist/cjs/ui/modal-create/main.js +9 -17
- package/dist/es2019/common/constants.js +1 -1
- package/dist/es2019/common/ui/error-boundary-modal/index.js +1 -0
- package/dist/es2019/common/ui/error-boundary-ui/error-svg/index.js +1 -0
- package/dist/es2019/controllers/create-field/main.js +1 -0
- package/dist/es2019/controllers/exit-warning-modal-context/index.js +30 -4
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/ui/create-form/async-select/main.js +2 -0
- package/dist/es2019/ui/create-form/form-footer/main.js +1 -0
- package/dist/es2019/ui/create-form/form-loader/main.js +2 -0
- package/dist/es2019/ui/create-form/main.js +3 -0
- package/dist/es2019/ui/create-form/select/main.js +1 -0
- package/dist/es2019/ui/create-form/textfield/main.js +1 -0
- package/dist/es2019/ui/create-form/user-picker/main.js +1 -0
- package/dist/es2019/ui/inline-create/index.js +2 -0
- package/dist/es2019/ui/inline-create/main.js +9 -15
- package/dist/es2019/ui/modal-create/index.js +2 -0
- package/dist/es2019/ui/modal-create/main.js +9 -13
- package/dist/esm/common/constants.js +1 -1
- package/dist/esm/common/ui/error-boundary-modal/index.js +1 -0
- package/dist/esm/common/ui/error-boundary-ui/error-svg/index.js +1 -0
- package/dist/esm/controllers/create-field/main.js +1 -0
- package/dist/esm/controllers/exit-warning-modal-context/index.js +40 -4
- package/dist/esm/index.js +1 -0
- package/dist/esm/ui/create-form/async-select/main.js +2 -0
- package/dist/esm/ui/create-form/form-footer/main.js +1 -0
- package/dist/esm/ui/create-form/form-loader/main.js +2 -0
- package/dist/esm/ui/create-form/main.js +3 -0
- package/dist/esm/ui/create-form/select/main.js +1 -0
- package/dist/esm/ui/create-form/textfield/main.js +1 -0
- package/dist/esm/ui/create-form/user-picker/main.js +1 -0
- package/dist/esm/ui/inline-create/index.js +2 -0
- package/dist/esm/ui/inline-create/main.js +10 -20
- package/dist/esm/ui/modal-create/index.js +2 -0
- package/dist/esm/ui/modal-create/main.js +10 -18
- package/dist/types/controllers/exit-warning-modal-context/index.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/ui/inline-create/main.d.ts +1 -0
- package/dist/types-ts4.5/controllers/exit-warning-modal-context/index.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/inline-create/main.d.ts +1 -0
- package/package.json +120 -118
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
|
|
3
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
5
|
import { Box } from '@atlaskit/primitives';
|
|
6
6
|
import { DEFAULT_TEST_ID, SCREEN_ID } from '../../common/constants';
|
|
@@ -10,7 +10,7 @@ import { ErrorBoundary } from '../../common/ui/error-boundary';
|
|
|
10
10
|
import { LinkCreateContent } from '../../common/ui/link-create-content';
|
|
11
11
|
import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
|
|
12
12
|
import { EditPostCreateModalProvider, useEditPostCreateModal } from '../../controllers/edit-post-create-context';
|
|
13
|
-
import {
|
|
13
|
+
import { useExitWarningModal } from '../../controllers/exit-warning-modal-context';
|
|
14
14
|
import { FormContextProvider } from '../../controllers/form-context';
|
|
15
15
|
import { LinkCreatePluginsProvider, useLinkCreatePlugins } from '../../controllers/plugin-context';
|
|
16
16
|
import { InlineAnalytics } from './inline-analytics';
|
|
@@ -24,27 +24,21 @@ const InlineCreateContent = ({
|
|
|
24
24
|
testId = DEFAULT_TEST_ID
|
|
25
25
|
}) => {
|
|
26
26
|
const {
|
|
27
|
-
|
|
27
|
+
withExitWarning,
|
|
28
|
+
showExitWarning,
|
|
29
|
+
setShowExitWarning
|
|
28
30
|
} = useExitWarningModal();
|
|
29
|
-
const [showExitWarning, setShowExitWarning] = useState(false);
|
|
30
31
|
const {
|
|
31
32
|
editViewPayload
|
|
32
33
|
} = useEditPostCreateModal();
|
|
33
34
|
const {
|
|
34
35
|
activePlugin
|
|
35
36
|
} = useLinkCreatePlugins();
|
|
36
|
-
const
|
|
37
|
-
if (getShouldShowWarning() && !showExitWarning) {
|
|
38
|
-
setShowExitWarning(true);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
42
|
-
}, [onCancel, getShouldShowWarning, showExitWarning]);
|
|
43
|
-
const handleCloseExitWarning = useCallback(() => setShowExitWarning(false), []);
|
|
37
|
+
const handleCloseExitWarning = () => setShowExitWarning(false);
|
|
44
38
|
return jsx(LinkCreateCallbackProvider, {
|
|
45
39
|
onCreate: onCreate,
|
|
46
40
|
onFailure: onFailure,
|
|
47
|
-
onCancel:
|
|
41
|
+
onCancel: withExitWarning(onCancel)
|
|
48
42
|
}, jsx(ErrorBoundary, null, jsx(InlineAnalytics, {
|
|
49
43
|
screen: SCREEN_ID
|
|
50
44
|
}, jsx(Box, {
|
|
@@ -76,7 +70,7 @@ const InlineCreate = props => {
|
|
|
76
70
|
var _pluginsProvider$acti;
|
|
77
71
|
return jsx(FormContextProvider, {
|
|
78
72
|
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
|
|
79
|
-
}, jsx(
|
|
73
|
+
}, jsx(InlineCreateContent, _extends({}, props, {
|
|
80
74
|
onCreate: async payload => {
|
|
81
75
|
var _props$onCreate;
|
|
82
76
|
await ((_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload));
|
|
@@ -92,7 +86,7 @@ const InlineCreate = props => {
|
|
|
92
86
|
}
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
|
-
})))
|
|
89
|
+
})));
|
|
96
90
|
}));
|
|
97
91
|
};
|
|
98
92
|
export default InlineCreate;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
5
|
import { jsx } from '@emotion/react';
|
|
4
6
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
7
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
3
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
6
|
import { jsx } from '@emotion/react';
|
|
5
7
|
import { useIntl } from 'react-intl-next';
|
|
6
8
|
import { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
@@ -34,31 +36,25 @@ const LinkCreateWithModal = ({
|
|
|
34
36
|
}) => {
|
|
35
37
|
const intl = useIntl();
|
|
36
38
|
const {
|
|
37
|
-
|
|
39
|
+
withExitWarning,
|
|
40
|
+
showExitWarning,
|
|
41
|
+
setShowExitWarning
|
|
38
42
|
} = useExitWarningModal();
|
|
39
|
-
const [showExitWarning, setShowExitWarning] = useState(false);
|
|
40
43
|
const {
|
|
41
44
|
editViewPayload
|
|
42
45
|
} = useEditPostCreateModal();
|
|
43
46
|
const {
|
|
44
47
|
activePlugin
|
|
45
48
|
} = useLinkCreatePlugins();
|
|
46
|
-
const
|
|
47
|
-
if (getShouldShowWarning() && !showExitWarning) {
|
|
48
|
-
setShowExitWarning(true);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
52
|
-
}, [onCancel, getShouldShowWarning, showExitWarning]);
|
|
53
|
-
const handleCloseExitWarning = useCallback(() => setShowExitWarning(false), []);
|
|
49
|
+
const handleCloseExitWarning = () => setShowExitWarning(false);
|
|
54
50
|
return jsx(LinkCreateCallbackProvider, {
|
|
55
51
|
onCreate: onCreate,
|
|
56
52
|
onFailure: onFailure,
|
|
57
|
-
onCancel:
|
|
53
|
+
onCancel: withExitWarning(onCancel)
|
|
58
54
|
}, jsx(ModalTransition, null, active && jsx(Modal, {
|
|
59
55
|
testId: "link-create-modal",
|
|
60
56
|
screen: SCREEN_ID,
|
|
61
|
-
onClose:
|
|
57
|
+
onClose: withExitWarning(onCancel),
|
|
62
58
|
shouldScrollInViewport: true,
|
|
63
59
|
onOpenComplete: onOpenComplete,
|
|
64
60
|
onCloseComplete: onCloseComplete,
|
|
@@ -7,7 +7,7 @@ export var CREATE_FORM_MIN_HEIGHT_IN_PX = '200';
|
|
|
7
7
|
export var LINK_CREATE_FORM_POST_CREATE_FIELD = '__post_create__';
|
|
8
8
|
export var PACKAGE_DATA = {
|
|
9
9
|
packageName: "@atlaskit/link-create" || '',
|
|
10
|
-
packageVersion: "2.
|
|
10
|
+
packageVersion: "2.5.0" || '',
|
|
11
11
|
component: COMPONENT_NAME,
|
|
12
12
|
componentName: COMPONENT_NAME
|
|
13
13
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
3
|
import { jsx } from '@emotion/react';
|
|
3
4
|
import Modal, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
|
|
4
5
|
import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../constants';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
4
|
import { css, jsx } from '@emotion/react';
|
|
4
5
|
var WIDTH = 82;
|
|
5
6
|
var errorStyles = css({
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
/** @jsx jsx */
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
6
|
import { css, jsx } from '@emotion/react';
|
|
6
7
|
import { Field } from 'react-final-form';
|
|
7
8
|
import { ErrorMessage, HelperMessage, Label, RequiredAsterisk } from '@atlaskit/form';
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
2
3
|
var ExitWarningModalContext = /*#__PURE__*/createContext({
|
|
3
4
|
getShouldShowWarning: function getShouldShowWarning() {
|
|
4
5
|
return false;
|
|
5
6
|
},
|
|
6
|
-
setShouldShowWarning: function setShouldShowWarning() {}
|
|
7
|
+
setShouldShowWarning: function setShouldShowWarning() {},
|
|
8
|
+
showExitWarning: false,
|
|
9
|
+
setShowExitWarning: function setShowExitWarning() {
|
|
10
|
+
return false;
|
|
11
|
+
},
|
|
12
|
+
withExitWarning: function withExitWarning() {
|
|
13
|
+
return function () {
|
|
14
|
+
return false;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
7
17
|
});
|
|
8
18
|
export var ExitWarningModalProvider = function ExitWarningModalProvider(_ref) {
|
|
9
19
|
var children = _ref.children;
|
|
20
|
+
var _useState = useState(false),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
showExitWarning = _useState2[0],
|
|
23
|
+
setShowExitWarning = _useState2[1];
|
|
10
24
|
var shouldShowWarning = useRef(false);
|
|
11
25
|
var getShouldShowWarning = useCallback(function () {
|
|
12
26
|
return shouldShowWarning.current;
|
|
@@ -14,12 +28,26 @@ export var ExitWarningModalProvider = function ExitWarningModalProvider(_ref) {
|
|
|
14
28
|
var setShouldShowWarning = useCallback(function (show) {
|
|
15
29
|
shouldShowWarning.current = show;
|
|
16
30
|
}, []);
|
|
31
|
+
var withExitWarning = useCallback(function (callback) {
|
|
32
|
+
return function () {
|
|
33
|
+
if (shouldShowWarning.current && !showExitWarning) {
|
|
34
|
+
setShowExitWarning(true);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
setShowExitWarning(false);
|
|
38
|
+
callback === null || callback === void 0 || callback(true);
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
41
|
+
}, [showExitWarning]);
|
|
17
42
|
var value = useMemo(function () {
|
|
18
43
|
return {
|
|
19
44
|
getShouldShowWarning: getShouldShowWarning,
|
|
20
|
-
setShouldShowWarning: setShouldShowWarning
|
|
45
|
+
setShouldShowWarning: setShouldShowWarning,
|
|
46
|
+
showExitWarning: showExitWarning,
|
|
47
|
+
setShowExitWarning: setShowExitWarning,
|
|
48
|
+
withExitWarning: withExitWarning
|
|
21
49
|
};
|
|
22
|
-
}, [getShouldShowWarning, setShouldShowWarning]);
|
|
50
|
+
}, [getShouldShowWarning, setShouldShowWarning, showExitWarning, setShowExitWarning, withExitWarning]);
|
|
23
51
|
return /*#__PURE__*/React.createElement(ExitWarningModalContext.Provider, {
|
|
24
52
|
value: value
|
|
25
53
|
}, children);
|
|
@@ -30,4 +58,12 @@ export var useExitWarningModal = function useExitWarningModal() {
|
|
|
30
58
|
throw new Error('useExitWarningModal used outside of ExitWarningModalProvider');
|
|
31
59
|
}
|
|
32
60
|
return value;
|
|
61
|
+
};
|
|
62
|
+
export var useWithExitWarning = function useWithExitWarning() {
|
|
63
|
+
var value = useContext(ExitWarningModalContext);
|
|
64
|
+
if (!value) {
|
|
65
|
+
throw new Error('useWithExitWarning used outside of ExitWarningModalProvider');
|
|
66
|
+
}
|
|
67
|
+
var withExitWarning = value.withExitWarning;
|
|
68
|
+
return withExitWarning;
|
|
33
69
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader,
|
|
|
3
3
|
//InlineCreate,
|
|
4
4
|
UserPicker } from './ui/index';
|
|
5
5
|
export { useLinkCreateCallback, LinkCreateCallbackProvider } from './controllers/callback-context';
|
|
6
|
+
export { ExitWarningModalProvider as LinkCreateExitWarningProvider, useWithExitWarning } from './controllers/exit-warning-modal-context';
|
|
6
7
|
export { FORM_ERROR } from 'final-form';
|
|
@@ -7,6 +7,8 @@ var _excluded = ["id", "name", "label", "isRequired", "validators", "validationH
|
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
/** @jsx jsx */
|
|
9
9
|
import { useEffect, useMemo, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
12
|
import { jsx } from '@emotion/react';
|
|
11
13
|
import debounce from 'debounce-promise';
|
|
12
14
|
import { useForm } from 'react-final-form';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import Spinner from '@atlaskit/spinner';
|
|
4
5
|
import { CREATE_FORM_MIN_HEIGHT_IN_PX } from '../../../common/constants';
|
|
@@ -6,6 +7,7 @@ var formLoaderStyles = css({
|
|
|
6
7
|
display: "flex",
|
|
7
8
|
alignItems: "center",
|
|
8
9
|
justifyContent: "center",
|
|
10
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
9
11
|
minHeight: "".concat(CREATE_FORM_MIN_HEIGHT_IN_PX, "px")
|
|
10
12
|
});
|
|
11
13
|
|
|
@@ -8,6 +8,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
8
8
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
9
|
/** @jsx jsx */
|
|
10
10
|
import { useCallback } from 'react';
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
13
|
import { css, jsx } from '@emotion/react';
|
|
12
14
|
import { FORM_ERROR } from 'final-form';
|
|
13
15
|
import { Form, FormSpy } from 'react-final-form';
|
|
@@ -22,6 +24,7 @@ import { useFormContext } from '../../controllers/form-context';
|
|
|
22
24
|
import { CreateFormFooter } from './form-footer';
|
|
23
25
|
import { CreateFormLoader } from './form-loader';
|
|
24
26
|
var formStyles = css({
|
|
27
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
25
28
|
maxWidth: "".concat(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")
|
|
@@ -4,6 +4,7 @@ var _excluded = ["id", "name", "label", "isRequired", "validators", "validationH
|
|
|
4
4
|
_excluded2 = ["fieldId"];
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
8
|
import { jsx } from '@emotion/react';
|
|
8
9
|
import AkSelect from '@atlaskit/select';
|
|
9
10
|
import { CreateField } from '../../../controllers/create-field';
|
|
@@ -3,6 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
3
3
|
var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId"],
|
|
4
4
|
_excluded2 = ["fieldId"];
|
|
5
5
|
/** @jsx jsx */
|
|
6
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
7
|
import { jsx } from '@emotion/react';
|
|
7
8
|
import AkTextfield from '@atlaskit/textfield';
|
|
8
9
|
import { CreateField } from '../../../controllers/create-field';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
var _excluded = ["fieldId"];
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
5
|
import { jsx } from '@emotion/react';
|
|
5
6
|
import SmartUserPicker from '@atlaskit/smart-user-picker';
|
|
6
7
|
import { CreateField } from '../../../controllers/create-field';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
5
|
import { jsx } from '@emotion/react';
|
|
4
6
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
7
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
4
|
/** @jsx jsx */
|
|
6
|
-
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
6
|
import { jsx } from '@emotion/react';
|
|
8
7
|
import { Box } from '@atlaskit/primitives';
|
|
9
8
|
import { DEFAULT_TEST_ID, SCREEN_ID } from '../../common/constants';
|
|
@@ -13,7 +12,7 @@ import { ErrorBoundary } from '../../common/ui/error-boundary';
|
|
|
13
12
|
import { LinkCreateContent } from '../../common/ui/link-create-content';
|
|
14
13
|
import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
|
|
15
14
|
import { EditPostCreateModalProvider, useEditPostCreateModal } from '../../controllers/edit-post-create-context';
|
|
16
|
-
import {
|
|
15
|
+
import { useExitWarningModal } from '../../controllers/exit-warning-modal-context';
|
|
17
16
|
import { FormContextProvider } from '../../controllers/form-context';
|
|
18
17
|
import { LinkCreatePluginsProvider, useLinkCreatePlugins } from '../../controllers/plugin-context';
|
|
19
18
|
import { InlineAnalytics } from './inline-analytics';
|
|
@@ -27,29 +26,20 @@ var InlineCreateContent = function InlineCreateContent(_ref) {
|
|
|
27
26
|
_ref$testId = _ref.testId,
|
|
28
27
|
testId = _ref$testId === void 0 ? DEFAULT_TEST_ID : _ref$testId;
|
|
29
28
|
var _useExitWarningModal = useExitWarningModal(),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
showExitWarning = _useState2[0],
|
|
34
|
-
setShowExitWarning = _useState2[1];
|
|
29
|
+
withExitWarning = _useExitWarningModal.withExitWarning,
|
|
30
|
+
showExitWarning = _useExitWarningModal.showExitWarning,
|
|
31
|
+
setShowExitWarning = _useExitWarningModal.setShowExitWarning;
|
|
35
32
|
var _useEditPostCreateMod = useEditPostCreateModal(),
|
|
36
33
|
editViewPayload = _useEditPostCreateMod.editViewPayload;
|
|
37
34
|
var _useLinkCreatePlugins = useLinkCreatePlugins(),
|
|
38
35
|
activePlugin = _useLinkCreatePlugins.activePlugin;
|
|
39
|
-
var
|
|
40
|
-
if (getShouldShowWarning() && !showExitWarning) {
|
|
41
|
-
setShowExitWarning(true);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
onCancel === null || onCancel === void 0 || onCancel();
|
|
45
|
-
}, [onCancel, getShouldShowWarning, showExitWarning]);
|
|
46
|
-
var handleCloseExitWarning = useCallback(function () {
|
|
36
|
+
var handleCloseExitWarning = function handleCloseExitWarning() {
|
|
47
37
|
return setShowExitWarning(false);
|
|
48
|
-
}
|
|
38
|
+
};
|
|
49
39
|
return jsx(LinkCreateCallbackProvider, {
|
|
50
40
|
onCreate: onCreate,
|
|
51
41
|
onFailure: onFailure,
|
|
52
|
-
onCancel:
|
|
42
|
+
onCancel: withExitWarning(onCancel)
|
|
53
43
|
}, jsx(ErrorBoundary, null, jsx(InlineAnalytics, {
|
|
54
44
|
screen: SCREEN_ID
|
|
55
45
|
}, jsx(Box, {
|
|
@@ -81,7 +71,7 @@ var InlineCreate = function InlineCreate(props) {
|
|
|
81
71
|
enableEditView = _ref2.enableEditView;
|
|
82
72
|
return jsx(FormContextProvider, {
|
|
83
73
|
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
|
|
84
|
-
}, jsx(
|
|
74
|
+
}, jsx(InlineCreateContent, _extends({}, props, {
|
|
85
75
|
onCreate: ( /*#__PURE__*/function () {
|
|
86
76
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload) {
|
|
87
77
|
var _props$onCreate;
|
|
@@ -111,7 +101,7 @@ var InlineCreate = function InlineCreate(props) {
|
|
|
111
101
|
return _ref3.apply(this, arguments);
|
|
112
102
|
};
|
|
113
103
|
}())
|
|
114
|
-
})))
|
|
104
|
+
})));
|
|
115
105
|
});
|
|
116
106
|
});
|
|
117
107
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
5
|
import { jsx } from '@emotion/react';
|
|
4
6
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
7
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
4
|
/** @jsx jsx */
|
|
6
|
-
import {
|
|
5
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
8
|
import { jsx } from '@emotion/react';
|
|
8
9
|
import { useIntl } from 'react-intl-next';
|
|
9
10
|
import { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
@@ -37,33 +38,24 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref) {
|
|
|
37
38
|
modalHero = _ref.modalHero;
|
|
38
39
|
var intl = useIntl();
|
|
39
40
|
var _useExitWarningModal = useExitWarningModal(),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
showExitWarning = _useState2[0],
|
|
44
|
-
setShowExitWarning = _useState2[1];
|
|
41
|
+
withExitWarning = _useExitWarningModal.withExitWarning,
|
|
42
|
+
showExitWarning = _useExitWarningModal.showExitWarning,
|
|
43
|
+
setShowExitWarning = _useExitWarningModal.setShowExitWarning;
|
|
45
44
|
var _useEditPostCreateMod = useEditPostCreateModal(),
|
|
46
45
|
editViewPayload = _useEditPostCreateMod.editViewPayload;
|
|
47
46
|
var _useLinkCreatePlugins = useLinkCreatePlugins(),
|
|
48
47
|
activePlugin = _useLinkCreatePlugins.activePlugin;
|
|
49
|
-
var
|
|
50
|
-
if (getShouldShowWarning() && !showExitWarning) {
|
|
51
|
-
setShowExitWarning(true);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
onCancel === null || onCancel === void 0 || onCancel();
|
|
55
|
-
}, [onCancel, getShouldShowWarning, showExitWarning]);
|
|
56
|
-
var handleCloseExitWarning = useCallback(function () {
|
|
48
|
+
var handleCloseExitWarning = function handleCloseExitWarning() {
|
|
57
49
|
return setShowExitWarning(false);
|
|
58
|
-
}
|
|
50
|
+
};
|
|
59
51
|
return jsx(LinkCreateCallbackProvider, {
|
|
60
52
|
onCreate: onCreate,
|
|
61
53
|
onFailure: onFailure,
|
|
62
|
-
onCancel:
|
|
54
|
+
onCancel: withExitWarning(onCancel)
|
|
63
55
|
}, jsx(ModalTransition, null, active && jsx(Modal, {
|
|
64
56
|
testId: "link-create-modal",
|
|
65
57
|
screen: SCREEN_ID,
|
|
66
|
-
onClose:
|
|
58
|
+
onClose: withExitWarning(onCancel),
|
|
67
59
|
shouldScrollInViewport: true,
|
|
68
60
|
onOpenComplete: onOpenComplete,
|
|
69
61
|
onCloseComplete: onCloseComplete,
|
|
@@ -2,9 +2,13 @@ import React from 'react';
|
|
|
2
2
|
type ExitWarningModalContextValue = {
|
|
3
3
|
getShouldShowWarning: () => boolean;
|
|
4
4
|
setShouldShowWarning: (show: boolean) => void;
|
|
5
|
+
showExitWarning: boolean;
|
|
6
|
+
setShowExitWarning: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
|
+
withExitWarning: (callback?: () => void) => () => boolean;
|
|
5
8
|
};
|
|
6
9
|
export declare const ExitWarningModalProvider: ({ children }: {
|
|
7
10
|
children: React.ReactNode;
|
|
8
11
|
}) => JSX.Element;
|
|
9
12
|
export declare const useExitWarningModal: () => ExitWarningModalContextValue;
|
|
13
|
+
export declare const useWithExitWarning: () => (callback?: () => void) => () => boolean;
|
|
10
14
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export type { CreateFormProps } from './ui/index';
|
|
|
2
2
|
export type { LinkCreateProps, LinkCreatePlugin, LinkCreateWithModalProps, CreatePayload, EditViewProps, } from './common/types';
|
|
3
3
|
export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy, UserPicker, } from './ui/index';
|
|
4
4
|
export { useLinkCreateCallback, LinkCreateCallbackProvider } from './controllers/callback-context';
|
|
5
|
+
export { ExitWarningModalProvider as LinkCreateExitWarningProvider, useWithExitWarning, } from './controllers/exit-warning-modal-context';
|
|
5
6
|
export type { Validator, ValidatorMap } from './common/types';
|
|
6
7
|
export { FORM_ERROR } from 'final-form';
|
|
@@ -2,9 +2,13 @@ import React from 'react';
|
|
|
2
2
|
type ExitWarningModalContextValue = {
|
|
3
3
|
getShouldShowWarning: () => boolean;
|
|
4
4
|
setShouldShowWarning: (show: boolean) => void;
|
|
5
|
+
showExitWarning: boolean;
|
|
6
|
+
setShowExitWarning: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
|
+
withExitWarning: (callback?: () => void) => () => boolean;
|
|
5
8
|
};
|
|
6
9
|
export declare const ExitWarningModalProvider: ({ children }: {
|
|
7
10
|
children: React.ReactNode;
|
|
8
11
|
}) => JSX.Element;
|
|
9
12
|
export declare const useExitWarningModal: () => ExitWarningModalContextValue;
|
|
13
|
+
export declare const useWithExitWarning: () => (callback?: () => void) => () => boolean;
|
|
10
14
|
export {};
|
|
@@ -2,5 +2,6 @@ export type { CreateFormProps } from './ui/index';
|
|
|
2
2
|
export type { LinkCreateProps, LinkCreatePlugin, LinkCreateWithModalProps, CreatePayload, EditViewProps, } from './common/types';
|
|
3
3
|
export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy, UserPicker, } from './ui/index';
|
|
4
4
|
export { useLinkCreateCallback, LinkCreateCallbackProvider } from './controllers/callback-context';
|
|
5
|
+
export { ExitWarningModalProvider as LinkCreateExitWarningProvider, useWithExitWarning, } from './controllers/exit-warning-modal-context';
|
|
5
6
|
export type { Validator, ValidatorMap } from './common/types';
|
|
6
7
|
export { FORM_ERROR } from 'final-form';
|